6 changed files with 281 additions and 25 deletions
@ -0,0 +1,63 @@ |
|||||||
|
<?xml version="1.0" encoding="utf-8"?> |
||||||
|
<Window |
||||||
|
x:Class="Gui.Dialogs.ReferenceDialog.AddServiceReferenceDialog" |
||||||
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" |
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" |
||||||
|
xmlns:widgets="http://icsharpcode.net/sharpdevelop/widgets" |
||||||
|
xmlns:core="http://icsharpcode.net/sharpdevelop/core" |
||||||
|
xmlns:src="clr-namespace:Gui.Dialogs.ReferenceDialog" |
||||||
|
WindowStartupLocation="CenterOwner" |
||||||
|
Style="{x:Static core:GlobalStyles.DialogWindowStyle}" |
||||||
|
Height="425" |
||||||
|
Width="500" |
||||||
|
Title="{Binding Title}"> |
||||||
|
|
||||||
|
<Grid Name="grid"> |
||||||
|
<Grid.RowDefinitions> |
||||||
|
<RowDefinition |
||||||
|
Height="1*" /> |
||||||
|
<RowDefinition |
||||||
|
Height="Auto" /> |
||||||
|
</Grid.RowDefinitions> |
||||||
|
|
||||||
|
<Grid Grid.Row="0"> |
||||||
|
<Grid.RowDefinitions> |
||||||
|
<RowDefinition Height="30"></RowDefinition> |
||||||
|
<RowDefinition Height="Auto"></RowDefinition> |
||||||
|
</Grid.RowDefinitions> |
||||||
|
|
||||||
|
<TextBox Grid.Row="0" Text="Bla bla bla"></TextBox> |
||||||
|
<Grid Grid.Row="1" ShowGridLines="True"> |
||||||
|
<Grid.ColumnDefinitions> |
||||||
|
<ColumnDefinition Width="300"></ColumnDefinition> |
||||||
|
<ColumnDefinition></ColumnDefinition> |
||||||
|
</Grid.ColumnDefinitions> |
||||||
|
<TextBox Grid.Column="0" Background="Yellow" Margin="2,4,2,4"></TextBox> |
||||||
|
|
||||||
|
<widgets:UniformGridWithSpacing Columns="2" Grid.Column="1" HorizontalAlignment="Center"> |
||||||
|
<Button |
||||||
|
Content="Go" |
||||||
|
Style="{x:Static core:GlobalStyles.ButtonStyle}" /> |
||||||
|
<Button |
||||||
|
Content="Discover" |
||||||
|
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"> |
||||||
|
<Button |
||||||
|
Content="{core:Localize Global.OKButtonText}" |
||||||
|
IsDefault="True" |
||||||
|
Name="okButton" |
||||||
|
Style="{x:Static core:GlobalStyles.ButtonStyle}" |
||||||
|
Click="okButtonClick" /> |
||||||
|
<Button |
||||||
|
Content="{core:Localize Global.CancelButtonText}" |
||||||
|
IsCancel="True" |
||||||
|
Name="cancelButton" |
||||||
|
Style="{x:Static core:GlobalStyles.ButtonStyle}" |
||||||
|
Click="cancelButtonClick" /> |
||||||
|
</widgets:UniformGridWithSpacing> |
||||||
|
</Grid> |
||||||
|
</Window> |
||||||
@ -0,0 +1,121 @@ |
|||||||
|
/* |
||||||
|
* Created by SharpDevelop. |
||||||
|
* User: Peter Forstmeier |
||||||
|
* Date: 12.10.2011 |
||||||
|
* Time: 20:05 |
||||||
|
* |
||||||
|
* To change this template use Tools | Options | Coding | Edit Standard Headers. |
||||||
|
*/ |
||||||
|
using System; |
||||||
|
using System.ComponentModel; |
||||||
|
using System.Linq.Expressions; |
||||||
|
using System.Reflection; |
||||||
|
|
||||||
|
using ICSharpCode.SharpDevelop.Project; |
||||||
|
|
||||||
|
namespace Gui.Dialogs.ReferenceDialog |
||||||
|
{ |
||||||
|
/// <summary>
|
||||||
|
/// Description of AddServiceReferenceViewModel.
|
||||||
|
/// </summary>
|
||||||
|
public class AddServiceReferenceViewModel:ViewModelBase |
||||||
|
{ |
||||||
|
public AddServiceReferenceViewModel(IProject project) |
||||||
|
{ |
||||||
|
Project = project; |
||||||
|
title = "Add Service Reference to <" + Project.Name +">"; |
||||||
|
discoverButtonContend = "Disvover"; |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
private string title; |
||||||
|
public string Title |
||||||
|
{ |
||||||
|
get {return title;} |
||||||
|
set {title = value; |
||||||
|
base.RaisePropertyChanged(() =>Title); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
private string discoverButtonContend; |
||||||
|
|
||||||
|
public string DiscoverButtonContend { |
||||||
|
get { return discoverButtonContend; } |
||||||
|
set { discoverButtonContend = value; |
||||||
|
base.RaisePropertyChanged(() =>DiscoverButtonContend);} |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
private IProject project; |
||||||
|
|
||||||
|
public IProject Project |
||||||
|
{ |
||||||
|
get {return project;} |
||||||
|
set {project = value; |
||||||
|
base.RaisePropertyChanged(() =>Project); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
public class ViewModelBase:INotifyPropertyChanged |
||||||
|
{ |
||||||
|
public ViewModelBase() |
||||||
|
{ |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
public event PropertyChangedEventHandler PropertyChanged; |
||||||
|
|
||||||
|
protected virtual void OnPropertyChanged(PropertyChangedEventArgs e) |
||||||
|
{ |
||||||
|
var handler = this.PropertyChanged; |
||||||
|
if (handler != null) |
||||||
|
{ |
||||||
|
handler(this, e); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
protected void RaisePropertyChanged<T>(Expression<Func<T>> propertyExpresssion) |
||||||
|
{ |
||||||
|
var propertyName = ExtractPropertyName(propertyExpresssion); |
||||||
|
this.RaisePropertyChanged(propertyName); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
protected void RaisePropertyChanged(String propertyName) |
||||||
|
{ |
||||||
|
OnPropertyChanged(new PropertyChangedEventArgs(propertyName)); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
private static String ExtractPropertyName<T>(Expression<Func<T>> propertyExpresssion) |
||||||
|
{ |
||||||
|
if (propertyExpresssion == null) |
||||||
|
{ |
||||||
|
throw new ArgumentNullException("propertyExpresssion"); |
||||||
|
} |
||||||
|
|
||||||
|
var memberExpression = propertyExpresssion.Body as MemberExpression; |
||||||
|
if (memberExpression == null) |
||||||
|
{ |
||||||
|
throw new ArgumentException("The expression is not a member access expression.", "propertyExpresssion"); |
||||||
|
} |
||||||
|
|
||||||
|
var property = memberExpression.Member as PropertyInfo; |
||||||
|
if (property == null) |
||||||
|
{ |
||||||
|
throw new ArgumentException("The member access expression does not access a property.", "propertyExpresssion"); |
||||||
|
} |
||||||
|
|
||||||
|
var getMethod = property.GetGetMethod(true); |
||||||
|
if (getMethod.IsStatic) |
||||||
|
{ |
||||||
|
throw new ArgumentException("The referenced property is a static property.", "propertyExpresssion"); |
||||||
|
} |
||||||
|
|
||||||
|
return memberExpression.Member.Name; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
Loading…
Reference in new issue