Browse Source

Editable Combobox, base Layout for mainContend Area

pull/23/head
PeterForstmeier 14 years ago
parent
commit
0f0851591e
  1. 4
      src/Main/Base/Project/ICSharpCode.SharpDevelop.addin
  2. 72
      src/Main/Base/Project/Src/Gui/Dialogs/ReferenceDialog/AddServiceReferenceDialog.xaml
  3. 253
      src/Main/Base/Project/Src/Gui/Dialogs/ReferenceDialog/AddServiceReferenceViewModel.cs

4
src/Main/Base/Project/ICSharpCode.SharpDevelop.addin

@ -314,12 +314,12 @@ @@ -314,12 +314,12 @@
label = "Show Service in Browser"
class = "ICSharpCode.SharpDevelop.Project.Commands.ShowServiceInBrowser"/>
</Condition>
<!--
<Condition name = "WriteableProject">
<MenuItem id = "AddServiceReference"
label = "Add Service Reference"
class = "ICSharpCode.SharpDevelop.Project.Commands.AddServiceReferenceToProject"/>
</Condition>-->
</Condition>
<MenuItem id = "AddSeparator" type = "Separator"/>
</Condition>

72
src/Main/Base/Project/Src/Gui/Dialogs/ReferenceDialog/AddServiceReferenceDialog.xaml

@ -12,40 +12,98 @@ @@ -12,40 +12,98 @@
Width="500"
Title="{Binding Title}">
<Grid Name="grid">
<Grid Name="grid" ShowGridLines="True">
<Grid.RowDefinitions>
<RowDefinition
Height="1*" />
<RowDefinition Height="3*"></RowDefinition>
<RowDefinition
Height="Auto" />
</Grid.RowDefinitions>
<Grid Grid.Row="0">
<Grid.RowDefinitions>
<RowDefinition Height="30"></RowDefinition>
<RowDefinition Height="40"></RowDefinition>
<RowDefinition Height="Auto"></RowDefinition>
</Grid.RowDefinitions>
<TextBox Grid.Row="0" Text="Bla bla bla"></TextBox>
<TextBox Grid.Row="0"
TextWrapping="Wrap"
Text="To see a list of available services on an specific Server,
enter a service URL and click Go.To browse for available services cklick Discover"
></TextBox>
<Grid Grid.Row="1" ShowGridLines="True">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"></RowDefinition>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="300"></ColumnDefinition>
<ColumnDefinition></ColumnDefinition>
</Grid.ColumnDefinitions>
<TextBox Grid.Column="0" Background="Yellow" Margin="2,4,2,4"></TextBox>
<!-- editable combo
http://stackoverflow.com/questions/582232/wpf-editable-combobox
http://stackoverflow.com/questions/3373239/wpf-editable-combobox
-->
<ComboBox Grid.Column="0" Margin="0,4,12,12"
IsEditable="True"
ItemsSource="{Binding MruServices}"
IsSynchronizedWithCurrentItem="True"
LostFocus="Cbo_LostFocus"
SelectedItem="{Binding SelectedService, UpdateSourceTrigger=PropertyChanged}">
</ComboBox>
<widgets:UniformGridWithSpacing Columns="2" Grid.Column="1" HorizontalAlignment="Center">
<widgets:UniformGridWithSpacing Columns="2" Grid.Column="1" Margin="0,4,12,12" HorizontalAlignment="Center">
<Button
Content="Go"
Command="{Binding GoCommand}"
Style="{x:Static core:GlobalStyles.ButtonStyle}" />
<Button
Content="Discover"
Style="{x:Static core:GlobalStyles.ButtonStyle}" />
Command="{Binding DiscoverCommand}"
Style="{x:Static core:GlobalStyles.ButtonStyle}"/>
</widgets:UniformGridWithSpacing>
</Grid>
</Grid>
<widgets:UniformGridWithSpacing Columns="2" Grid.Column="0" Grid.Row="1" HorizontalAlignment="Right" Margin="0,4,12,12">
<!-- Main Area -->
<Grid Grid.Row="1">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="100"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<!-- http://www.c-sharpcorner.com/UploadFile/mahesh/WPFTreeView08202008231544PM/WPFTreeView.aspx-->
<TreeView HorizontalAlignment="Left"
VerticalAlignment="Top" >
<TreeViewItem Header="Cold Drinks">
<TreeViewItem Header="Coke"></TreeViewItem>
<TreeViewItem Header="Pepsi"></TreeViewItem>
<TreeViewItem Header="Orange Juice"></TreeViewItem>
<TreeViewItem Header="Milk"></TreeViewItem>
<TreeViewItem Header="Iced Tea"></TreeViewItem>
<TreeViewItem Header="Mango Shake"></TreeViewItem>
</TreeViewItem>
</TreeView>
<GridSplitter Grid.Column="0" Width="2" />
<Label Background="Green" Grid.Column="1"/>
</Grid>
<widgets:UniformGridWithSpacing Columns="2" Grid.Column="0" Grid.Row="2" HorizontalAlignment="Right" Margin="0,4,12,12">
<Button
Content="{core:Localize Global.OKButtonText}"
IsDefault="True"

253
src/Main/Base/Project/Src/Gui/Dialogs/ReferenceDialog/AddServiceReferenceViewModel.cs

@ -7,11 +7,16 @@ @@ -7,11 +7,16 @@
* To change this template use Tools | Options | Coding | Edit Standard Headers.
*/
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Linq.Expressions;
using System.Reflection;
using System.Windows;
using System.Windows.Input;
using ICSharpCode.SharpDevelop.Project;
using Microsoft.Win32;
namespace Gui.Dialogs.ReferenceDialog
{
@ -20,11 +25,34 @@ namespace Gui.Dialogs.ReferenceDialog @@ -20,11 +25,34 @@ namespace Gui.Dialogs.ReferenceDialog
/// </summary>
public class AddServiceReferenceViewModel:ViewModelBase
{
string header1 = "To see a list of available services on an specific Server, ";
string header2 = "enter a service URL and click Go. To browse for available services click Discover";
string noUrl = "Please enter he address of the Service.";
string discoverMenu ="Services in Solution";
public AddServiceReferenceViewModel(IProject project)
{
Project = project;
title = "Add Service Reference to <" + Project.Name +">";
title = "Add Service Reference";
discoverButtonContend = "Disvover";
HeadLine = header1 + header2;
MruServices = AddMruList();
SelectedService = MruServices[0];
GoCommand = new RelayCommand(ExecuteGo,CanExecuteGo);
DiscoverCommand = new RelayCommand(ExecuteDiscover,CanExecuteDiscover);
}
private string art;
public string Art {
get { return art; }
set { art = value;
base.RaisePropertyChanged(() =>Art);
}
}
@ -36,7 +64,10 @@ namespace Gui.Dialogs.ReferenceDialog @@ -36,7 +64,10 @@ namespace Gui.Dialogs.ReferenceDialog
base.RaisePropertyChanged(() =>Title);
}
}
public string HeadLine {get; private set;}
private string discoverButtonContend;
public string DiscoverButtonContend {
@ -56,6 +87,81 @@ namespace Gui.Dialogs.ReferenceDialog @@ -56,6 +87,81 @@ namespace Gui.Dialogs.ReferenceDialog
}
}
#region Create List of services
// Modifyed Code from Matt
List <string> AddMruList()
{
var list = new List<string>();
try {
RegistryKey key = Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Internet Explorer\TypedURLs");
if (key != null) {
foreach (string name in key.GetValueNames()) {
list.Add ((string)key.GetValue(name));
}
}
} catch (Exception)
{
};
return list;
}
private List<string> mruServices;
public List<string> MruServices {
get {
if (mruServices == null) {
mruServices = new List<string>();
}
return mruServices; }
set { mruServices = value;
base.RaisePropertyChanged(() =>MruServices);
}
}
private string selectedService;
public string SelectedService {
get { return selectedService; }
set { selectedService = value;
base.RaisePropertyChanged(() =>SelectedService);}
}
#endregion
#region Go
public ICommand GoCommand {get; private set;}
private void ExecuteGo ()
{
string s = String.Format("<Go> with Service <{0}>",SelectedService);
MessageBox.Show (s);
}
private bool CanExecuteGo()
{
return true;
}
#endregion
#region Discover
public ICommand DiscoverCommand {get;private set;}
private bool CanExecuteDiscover ()
{
return true;
}
private void ExecuteDiscover ()
{
MessageBox.Show ("<Discover> is not implemented at the Moment");
}
#endregion
}
public class ViewModelBase:INotifyPropertyChanged
@ -118,4 +224,147 @@ namespace Gui.Dialogs.ReferenceDialog @@ -118,4 +224,147 @@ namespace Gui.Dialogs.ReferenceDialog
return memberExpression.Member.Name;
}
}
public class RelayCommand<T> : ICommand
{
#region Declarations
readonly Predicate<T> _canExecute;
readonly Action<T> _execute;
#endregion
#region Constructors
/// <summary>
/// Initializes a new instance of the <see cref="RelayCommand&lt;T&gt;"/> class and the command can always be executed.
/// </summary>
/// <param name="execute">The execution logic.</param>
public RelayCommand(Action<T> execute)
: this(execute, null)
{
}
/// <summary>
/// Initializes a new instance of the <see cref="RelayCommand&lt;T&gt;"/> class.
/// </summary>
/// <param name="execute">The execution logic.</param>
/// <param name="canExecute">The execution status logic.</param>
public RelayCommand(Action<T> execute, Predicate<T> canExecute)
{
if (execute == null)
throw new ArgumentNullException("execute");
_execute = execute;
_canExecute = canExecute;
}
#endregion
#region ICommand Members
public event EventHandler CanExecuteChanged
{
add
{
if (_canExecute != null)
CommandManager.RequerySuggested += value;
}
remove
{
if (_canExecute != null)
CommandManager.RequerySuggested -= value;
}
}
[DebuggerStepThrough]
public Boolean CanExecute(Object parameter)
{
return _canExecute == null ? true : _canExecute((T)parameter);
}
public void Execute(Object parameter)
{
_execute((T)parameter);
}
#endregion
}
/// <summary>
/// A command whose sole purpose is to relay its functionality to other objects by invoking delegates. The default return value for the CanExecute method is 'true'.
/// </summary>
public class RelayCommand : ICommand
{
#region Declarations
readonly Func<Boolean> _canExecute;
readonly Action _execute;
#endregion
#region Constructors
/// <summary>
/// Initializes a new instance of the <see cref="RelayCommand&lt;T&gt;"/> class and the command can always be executed.
/// </summary>
/// <param name="execute">The execution logic.</param>
public RelayCommand(Action execute)
: this(execute, null)
{
}
/// <summary>
/// Initializes a new instance of the <see cref="RelayCommand&lt;T&gt;"/> class.
/// </summary>
/// <param name="execute">The execution logic.</param>
/// <param name="canExecute">The execution status logic.</param>
public RelayCommand(Action execute, Func<Boolean> canExecute)
{
if (execute == null)
throw new ArgumentNullException("execute");
_execute = execute;
_canExecute = canExecute;
}
#endregion
#region ICommand Members
public event EventHandler CanExecuteChanged
{
add
{
if (_canExecute != null)
CommandManager.RequerySuggested += value;
}
remove
{
if (_canExecute != null)
CommandManager.RequerySuggested -= value;
}
}
[DebuggerStepThrough]
public Boolean CanExecute(Object parameter)
{
return _canExecute == null ? true : _canExecute();
}
public void Execute(Object parameter)
{
_execute();
}
#endregion
}
}

Loading…
Cancel
Save