Browse files

Rearrange Messages, cleanup

  • Loading branch information...
1 parent 20fb4fc commit abd2ca7ac4005324b9fbc67c700e42cccacea82d @PeterForstmeier PeterForstmeier committed Oct 29, 2011
View
171 src/Main/Base/Project/Src/Gui/Dialogs/ReferenceDialog/AddServiceReferenceDialog.xaml
@@ -9,7 +9,7 @@
xmlns:web="clr-namespace:System.Web.Services.Description;assembly=System.Web.Services"
WindowStartupLocation="CenterOwner"
Style="{x:Static core:GlobalStyles.DialogWindowStyle}"
- Height="570"
+ Height="600"
Width="700"
Title="{Binding Title}">
@@ -24,101 +24,108 @@ http://www.codeproject.com/KB/WPF/TreeViewWithViewModel.aspx?msg=3663052
ItemsSource="{Binding SubItems}">
<TextBlock Grid.Row="0" Text="{Binding Path=Name}" />
</HierarchicalDataTemplate>
- </Window.Resources>
-
-<!-- Style="{x:Static core:GlobalStyles.ButtonStyle}" -->
-
+ </Window.Resources>
+
<Grid>
-
<Grid.RowDefinitions>
<RowDefinition Height="2*" />
<RowDefinition Height="*"></RowDefinition>
- <RowDefinition Height="*"></RowDefinition>
- <RowDefinition Height="*"></RowDefinition>
+ <RowDefinition Height="25"></RowDefinition>
+ <RowDefinition Height="5"></RowDefinition>
<RowDefinition Height="7*"></RowDefinition>
<RowDefinition Height="2*"></RowDefinition>
- <RowDefinition Height="*"></RowDefinition>
- <RowDefinition Height="*"></RowDefinition>
- <RowDefinition Height="*"></RowDefinition>
+ <RowDefinition Height="20"></RowDefinition>
+ <RowDefinition Height="30"></RowDefinition>
+ <RowDefinition Height="40"></RowDefinition>
</Grid.RowDefinitions>
- <Grid.ColumnDefinitions>
- <ColumnDefinition Width="200"></ColumnDefinition>
- <ColumnDefinition Width="*"></ColumnDefinition>
- <ColumnDefinition Width="*"></ColumnDefinition>
- </Grid.ColumnDefinitions>
<TextBox Grid.ColumnSpan="3"
Margin="4,0,4,0"
- TextWrapping="Wrap"
- Text="To see a list of available services on an specific Server,&#xD;&#xA;&#x9;&#x9;&#x9;enter a service URL and click Go.To browse for available services cklick Discover"></TextBox>
+ TextWrapping="Wrap"
+ Text="{Binding HeadLine}">
+ </TextBox>
- <TextBlock Grid.Row="1" Text="Address:" Margin="4,0,4,0"></TextBlock>
+ <TextBlock Grid.Row="1" Text="Address:" Margin="5,0,4,0" VerticalAlignment="Bottom"></TextBlock>
- <ComboBox
- Grid.Row="2"
- Grid.ColumnSpan="2"
- Margin="4,0,4,0"
- IsEditable="True"
- ItemsSource="{Binding MruServices}"
- IsSynchronizedWithCurrentItem="True"
- LostFocus="Cbo_LostFocus"
- SelectedItem="{Binding SelectedService, UpdateSourceTrigger=PropertyChanged}">
- </ComboBox>
- <StackPanel Grid.Column="2"
- Grid.Row="2"
- Margin="4,0,4,0"
- Orientation="Horizontal">
- <Button
- Content="Go"
- Width="30"
- Margin="4,0,2,0"
- HorizontalContentAlignment="Center"
- Command="{Binding GoCommand}"
- Style="{x:Static core:GlobalStyles.ButtonStyle}"/>
+ <Grid Grid.Row="2">
+ <Grid.ColumnDefinitions>
+ <ColumnDefinition Width="2*"></ColumnDefinition>
+ <ColumnDefinition Width="*"></ColumnDefinition>
+ </Grid.ColumnDefinitions>
+ <ComboBox
+ Margin="4,0,4,0"
+ IsEditable="True"
+ ItemsSource="{Binding MruServices}"
+ IsSynchronizedWithCurrentItem="True"
+ LostFocus="Cbo_LostFocus"
+ SelectedItem="{Binding SelectedService, UpdateSourceTrigger=PropertyChanged}">
+ </ComboBox>
- <Button
- Content="Discover"
- Margin="2,0,0,0"
- HorizontalContentAlignment="Center"
- Command="{Binding DiscoverCommand}"
- Style="{x:Static core:GlobalStyles.ButtonStyle}"/>
-
- </StackPanel>
-
- <TextBlock Grid.Row="3" Text="Service:" Margin="4,0,4,0"></TextBlock>
+ <widgets:UniformGridWithSpacing
+ Columns="2"
+ Grid.Column="1"
+ HorizontalAlignment="Left"
+ Margin="4,0,4,0">
+ <Button
+ Content="Go" HorizontalContentAlignment="Center"
+ Command="{Binding GoCommand}" />
+
+ <Button
+ Content="Discover" HorizontalContentAlignment="Center"
+ Command="{Binding DiscoverCommand}" />
+
+ </widgets:UniformGridWithSpacing>
+ </Grid>
- <TreeView
- Grid.Row="4" Margin="4"
+ <!-- main area -->
+ <Grid Grid.Row="4" >
+ <Grid.RowDefinitions>
+ <RowDefinition Height="20"></RowDefinition>
+ <RowDefinition></RowDefinition>
+ </Grid.RowDefinitions>
+ <Grid.ColumnDefinitions>
+ <ColumnDefinition Width="*"></ColumnDefinition>
+ <ColumnDefinition Width="2*"></ColumnDefinition>
+ </Grid.ColumnDefinitions>
+ <TextBlock Text="Service:" Margin="4,0,4,0"></TextBlock>
+ <TextBlock Grid.Column="1" Text="Service:" Margin="4,0,4,0"></TextBlock>
+ <TreeView
+ Grid.Row="1"
+ Grid.Column="0"
+ Margin="4"
Name="tree"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
ItemsSource="{Binding Path=ServiceItems}"
ItemTemplate="{StaticResource HeaderTemplate}"
SelectedItemChanged="Tree_SelectedItemChanged">
- </TreeView>
-
- <GridSplitter
- Grid.Column="0"
- Grid.Row="4"
- Width="2"/>
-
- <ListView
- Grid.Column="1" Grid.Row="4" Grid.ColumnSpan="2" Margin="4"
- ItemsSource="{Binding Path=TwoValues}">
- <ListView.View>
- <GridView>
- <GridViewColumn Header="Poperty" Width="150" DisplayMemberBinding="{Binding LeftValue}"></GridViewColumn>
- <GridViewColumn Header="Value" Width="150" DisplayMemberBinding="{Binding RightValue}"></GridViewColumn>
- </GridView>
- </ListView.View>
- </ListView>
+ </TreeView>
+
+ <GridSplitter
+ Grid.Row="1"
+ Grid.Column="0"
+ Width="2"/>
+ <ListView
+ Grid.Column="1" Grid.Row="1" Margin="4"
+ ItemsSource="{Binding Path=TwoValues}">
+ <ListView.View>
+ <GridView>
+ <GridViewColumn Header="Poperty" Width="150" DisplayMemberBinding="{Binding LeftValue}"></GridViewColumn>
+ <GridViewColumn Header="Value" Width="150" DisplayMemberBinding="{Binding RightValue}"></GridViewColumn>
+ </GridView>
+ </ListView.View>
+ </ListView>
+ </Grid>
<Border Grid.Row="5" Grid.ColumnSpan="3" Margin="4,0,4,0" BorderThickness="2" BorderBrush="LightGray">
- <TextBlock></TextBlock>
+ <TextBlock Text="{Binding ServiceDescriptionMessage}"></TextBlock>
</Border>
- <TextBlock Grid.Row="6" Text="NameSpace:" Margin="4,0,4,0"></TextBlock>
- <TextBox Grid.Row="7" Grid.ColumnSpan="3" Margin="4"></TextBox>
+ <TextBlock Grid.Row="6" Text="NameSpace:" Margin="4,0,4,0" VerticalAlignment="Bottom"></TextBlock>
+ <TextBox Grid.Row="7" Grid.ColumnSpan="3"
+ Margin="4" Background="White"
+ Text="{Binding DefaultNameSpace}">
+ </TextBox>
<widgets:UniformGridWithSpacing
Columns="2"
@@ -139,25 +146,5 @@ http://www.codeproject.com/KB/WPF/TreeViewWithViewModel.aspx?msg=3663052
Style="{x:Static core:GlobalStyles.ButtonStyle}"
Click="cancelButtonClick" />
</widgets:UniformGridWithSpacing>
-
- <!--
- <widgets:UniformGridWithSpacing Background="Green"
- Columns="3"
- Grid.Column="2"
- Margin="4,4,12,12"
- HorizontalAlignment="Center">
-
- <Button
- Content="Go" HorizontalContentAlignment="Center"
- Command="{Binding GoCommand}" />
-
- <Button
- Content="Discover" HorizontalContentAlignment="Center"
- Command="{Binding DiscoverCommand}" />
-
- </widgets:UniformGridWithSpacing>
- </Grid>
- </Grid>
- -->
</Grid>
</Window>
View
222 src/Main/Base/Project/Src/Gui/Dialogs/ReferenceDialog/AddServiceReferenceViewModel.cs
@@ -38,13 +38,33 @@ 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 the address of the Service.";
-// string discoverMenu ="Services in Solution";
+ string title = "Add Service Reference";
+ string defaultNameSpace;
+ string serviceDescriptionMessage;
+ string namespacePrefix = String.Empty;
+
+ private ObservableCollection<TwoValue> twoValues;
+
+ private List<string> mruServices = new List<string>();
+ private string selectedService;
+ private IProject project;
+
+ List<ServiceItem> items = new List <ServiceItem>();
+ ServiceItem myItem;
+
Uri discoveryUri;
+ ServiceDescriptionCollection serviceDescriptionCollection = new ServiceDescriptionCollection();
+ CredentialCache credentialCache = new CredentialCache();
+ WebServiceDiscoveryClientProtocol discoveryClientProtocol;
+
+ delegate DiscoveryDocument DiscoverAnyAsync(string url);
+ delegate void DiscoveredWebServicesHandler(DiscoveryClientProtocol protocol);
+ delegate void AuthenticationHandler(Uri uri, string authenticationType);
+
public AddServiceReferenceViewModel(IProject project)
{
- Project = project;
- title = "Add Service Reference";
+ project = project;
discoverButtonContend = "Disvover";
HeadLine = header1 + header2;
@@ -56,70 +76,6 @@ public AddServiceReferenceViewModel(IProject project)
TwoValues = new ObservableCollection<TwoValue>();
}
- private string art;
-
- public string Art {
- get { return art; }
- set { art = value;
- base.RaisePropertyChanged(() =>Art);
- }
- }
-
-
- private string title;
- public string Title
- {
- get {return title;}
- set {title = value;
- base.RaisePropertyChanged(() =>Title);
- }
- }
-
-
- public string HeadLine {get; private set;}
-
- 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);
- }
- }
-
-
- #region Create List of services
-
- private List<string> mruServices = new List<string>();
-
- public List<string> MruServices {
- get {
- 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
@@ -134,6 +90,7 @@ private void ExecuteGo ()
StartDiscovery(uri, new DiscoveryNetworkCredential(CredentialCache.DefaultNetworkCredentials, DiscoveryNetworkCredential.DefaultAuthenticationType));
}
+
private bool CanExecuteGo()
{
return true;
@@ -142,7 +99,7 @@ private bool CanExecuteGo()
#endregion
- #region Discover
+ #region Discover Command
public System.Windows.Input.ICommand DiscoverCommand {get;private set;}
@@ -160,18 +117,7 @@ private void ExecuteDiscover ()
#region discover service Code from Matt
-
-
- CredentialCache credentialCache = new CredentialCache();
- WebServiceDiscoveryClientProtocol discoveryClientProtocol;
-// ICSharpCode.SharpDevelop.Gui.WebReference webReference;
- string namespacePrefix = String.Empty;
- delegate DiscoveryDocument DiscoverAnyAsync(string url);
- delegate void DiscoveredWebServicesHandler(DiscoveryClientProtocol protocol);
- delegate void AuthenticationHandler(Uri uri, string authenticationType);
-
-
-
+
void StartDiscovery(Uri uri, DiscoveryNetworkCredential credential)
{
// Abort previous discovery.
@@ -262,7 +208,7 @@ void AuthenticateUser(Uri uri, string authenticationType)
}
- void AddCredential(Uri uri, DiscoveryNetworkCredential credential)
+ void AddCredential(Uri uri, DiscoveryNetworkCredential credential)
{
NetworkCredential matchedCredential = credentialCache.GetCredential(uri, credential.AuthenticationType);
if (matchedCredential != null) {
@@ -275,22 +221,14 @@ void AddCredential(Uri uri, DiscoveryNetworkCredential credential)
void DiscoveredWebServices(DiscoveryClientProtocol protocol)
{
if (protocol != null) {
-// webServicesView.Add(GetServiceDescriptions(protocol));
-
- ServiceDescriptionCollection = ServiceReferenceHelper.GetServiceDescriptions(protocol);
- FillItems (ServiceDescriptionCollection);
- var defaultNameSpace = GetDefaultNamespace();
+ serviceDescriptionCollection = ServiceReferenceHelper.GetServiceDescriptions(protocol);
+
+ ServiceDescriptionMessage = String.Format("{0} service(s) found at address {1}",
+ serviceDescriptionCollection.Count,
+ discoveryUri);
+ DefaultNameSpace = GetDefaultNamespace();
+ FillItems (serviceDescriptionCollection);
var referenceName = GetReferenceName(discoveryUri);
- /*
- webReference = new ICSharpCode.SharpDevelop.Gui.WebReference(project,
- discoveryUri.AbsoluteUri,
- defaultNameSpace,
- referenceName, protocol);
-*/
- }
- else
- {
-// webReference = null;
}
}
@@ -315,37 +253,49 @@ static string GetReferenceName(Uri uri)
return uri.Host;
}
return String.Empty;
- /*
- if (discoveryUri != null) {
- return discoveryUri.Host;
- }
- return String.Empty;
- */
}
+
+ #endregion
-
- ServiceDescriptionCollection serviceDescriptionCollection = new ServiceDescriptionCollection();
- public ServiceDescriptionCollection ServiceDescriptionCollection
+ #region new binding
+
+ public string Title
{
- get {
- return serviceDescriptionCollection;
- }
- set
- {
- serviceDescriptionCollection = value;
- RaisePropertyChanged(() =>ServiceDescriptionCollection);
+ get {return title;}
+ set {title = value;
+ base.RaisePropertyChanged(() =>Title);
}
}
+
- #endregion
+ public string HeadLine {get; set;}
+ private string discoverButtonContend;
- #region new binding
+ public string DiscoverButtonContend {
+ get { return discoverButtonContend; }
+ set { discoverButtonContend = value;
+ base.RaisePropertyChanged(() =>DiscoverButtonContend);}
+ }
- List<ServiceItem> items = new List <ServiceItem>();
+
+ public List<string> MruServices {
+ get {
+ return mruServices; }
+ set { mruServices = value;
+ base.RaisePropertyChanged(() =>MruServices);
+ }
+ }
+ public string SelectedService {
+ get { return selectedService; }
+ set { selectedService = value;
+ base.RaisePropertyChanged(() =>SelectedService);}
+ }
+
+
public List <ServiceItem> ServiceItems {
get {return items; }
@@ -356,8 +306,6 @@ public ServiceDescriptionCollection ServiceDescriptionCollection
}
- ServiceItem myItem;
-
public ServiceItem ServiceItem {
get { return myItem; }
set { myItem = value;
@@ -367,7 +315,20 @@ public ServiceDescriptionCollection ServiceDescriptionCollection
}
- private ObservableCollection<TwoValue> twoValues;
+ public string ServiceDescriptionMessage {
+ get { return serviceDescriptionMessage; }
+ set { serviceDescriptionMessage = value;
+ base.RaisePropertyChanged(() =>ServiceDescriptionMessage);
+ }
+ }
+
+
+ public string DefaultNameSpace {
+ get { return defaultNameSpace; }
+ set { defaultNameSpace = value;
+ base.RaisePropertyChanged(() =>DefaultNameSpace);}
+ }
+
public ObservableCollection<TwoValue> TwoValues {
get { return twoValues; }
@@ -378,7 +339,7 @@ public ServiceDescriptionCollection ServiceDescriptionCollection
}
- public void UpdateListView ()
+ void UpdateListView ()
{
TwoValues.Clear();
string l;
@@ -440,14 +401,14 @@ void FillItems (ServiceDescriptionCollection descriptions)
{
Add (element);
}
-
}
void Add(ServiceDescription description)
{
List<ServiceItem> l = new List<ServiceItem>();
- var rootNode = new ServiceItem(GetName(description));
+ var name = ServiceReferenceHelper.GetServiceName(description);
+ var rootNode = new ServiceItem(name);
rootNode.Tag = description;
l.Add(rootNode);
@@ -479,25 +440,8 @@ void Add(ServiceDescription description)
}
ServiceItems = l;
}
-
-
- string GetName(ServiceDescription description)
- {
- if (description.Name != null) {
- return description.Name;
- } else if (description.RetrievalUrl != null) {
- Uri uri = new Uri(description.RetrievalUrl);
- if (uri.Segments.Length > 0) {
- return uri.Segments[uri.Segments.Length - 1];
- } else {
- return uri.Host;
- }
- }
- return String.Empty;
- }
-
+
#endregion
-
}
View
17 src/Main/Base/Project/Src/Gui/Dialogs/ReferenceDialog/ServiceReferenceHelper.cs
@@ -55,5 +55,22 @@ public static ServiceDescriptionCollection GetServiceDescriptions(DiscoveryClien
}
return services;
}
+
+
+ public static string GetServiceName(ServiceDescription description)
+ {
+ if (description.Name != null) {
+ return description.Name;
+ } else if (description.RetrievalUrl != null) {
+ Uri uri = new Uri(description.RetrievalUrl);
+ if (uri.Segments.Length > 0) {
+ return uri.Segments[uri.Segments.Length - 1];
+ } else {
+ return uri.Host;
+ }
+ }
+ return String.Empty;
+ }
+
}
}

0 comments on commit abd2ca7

Please sign in to comment.