Browse Source

ReportWizard can select a Project in Solution

pull/685/head
Peter Forstmeier 10 years ago
parent
commit
ba82d9dea2
  1. 25
      src/AddIns/Misc/Reporting/ICSharpCode.Reporting.Addin/src/ReportWizard/Dialog/PushDataReport.xaml
  2. 65
      src/AddIns/Misc/Reporting/ICSharpCode.Reporting.Addin/src/ReportWizard/Dialog/PushDataReport.xaml.cs

25
src/AddIns/Misc/Reporting/ICSharpCode.Reporting.Addin/src/ReportWizard/Dialog/PushDataReport.xaml

@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
<xctk:WizardPage x:Class="ICSharpCode.Reporting.Addin.ReportWizard.Dialog.PushDataReport"
<xctk:WizardPage x:Class="ICSharpCode.Reporting.Addin.ReportWizard.Dialog.PushDataReport"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"
@ -12,7 +12,7 @@ @@ -12,7 +12,7 @@
CanSelectPreviousPage="true"
CanSelectNextPage="false">
<Grid ShowGridLines="True">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"></ColumnDefinition>
<ColumnDefinition></ColumnDefinition>
@ -20,21 +20,30 @@ @@ -20,21 +20,30 @@
<Grid.RowDefinitions>
<RowDefinition Height="30"></RowDefinition>
<RowDefinition Height="Auto"></RowDefinition>
<RowDefinition Height="200"></RowDefinition>
<RowDefinition Height="30"></RowDefinition>
<RowDefinition Height="30"></RowDefinition>
<RowDefinition Height="30"></RowDefinition>
<RowDefinition Height="30"></RowDefinition>
<RowDefinition Height="150"></RowDefinition>
</Grid.RowDefinitions>
<TextBlock Name="_projTxt" Text="{core:Localize SharpReport.Wizard.PushModel.SelectProject}"
<!-- Seelct project in Solution -->
<TextBlock Text="Select Project" FontSize="15" ></TextBlock>
<ComboBox Name="_projectsCbo" Grid.Row="1" SelectionChanged="_pro_SelectionChanged"></ComboBox>
<!-- Select Type from Solution -->
<TextBlock Name="_projTxt" Grid.Row="3" Visibility="Hidden" Text="{core:Localize SharpReport.Wizard.PushModel.SelectProject}"
FontSize="15" ></TextBlock>
<ComboBox Name="_cboTypes" Grid.Row="4" Visibility="Hidden" SelectionChanged="_cboTypes_SelectionChanged" MinWidth="150" ></ComboBox>
<ComboBox Name="_cboTypes" Visibility="Hidden" Grid.Row="1" SelectionChanged="_cboTypes_SelectionChanged" MinWidth="150" ></ComboBox>
<TextBlock Name="_availTxt" Visibility="Hidden" Text="{core:Localize SharpReport.Wizard.PushModel.AvailableFields}" FontSize="15" Grid.Column ="1" Margin="15,0,0,0"></TextBlock>
<TextBlock Name="_availTxt" Visibility="Hidden " Text="{core:Localize SharpReport.Wizard.PushModel.AvailableFields}" FontSize="15" Grid.Column ="1" Margin="15,0,0,0"></TextBlock>
<DataGrid Name="_DataGrid"
ItemsSource="{Binding}"
CanUserAddRows="True"
CanUserDeleteRows="True"
AutoGenerateColumns="False" Grid.Row="2" Grid.RowSpan="2" Margin="5,10,30,5" Width="400" Grid.Column="1">
AutoGenerateColumns="False" Grid.Row="1" Grid.RowSpan="5" Margin="5,10,30,5" Width="400" Grid.Column="1">
<DataGrid.Columns>
<DataGridTextColumn Header="ColumnName" Binding="{Binding ColumnName}" Width="200"></DataGridTextColumn>
<DataGridComboBoxColumn Header="DataType" x:Name="cboType" SelectedItemBinding="{Binding DataTypeName}" Width="*"></DataGridComboBoxColumn>

65
src/AddIns/Misc/Reporting/ICSharpCode.Reporting.Addin/src/ReportWizard/Dialog/PushDataReport.xaml.cs

@ -12,6 +12,8 @@ using System.Linq; @@ -12,6 +12,8 @@ using System.Linq;
using ICSharpCode.Core;
using ICSharpCode.NRefactory.TypeSystem;
using ICSharpCode.Reporting.BaseClasses;
using ICSharpCode.SharpDevelop.Dom;
using ICSharpCode.SharpDevelop.Project;
using Xceed.Wpf.Toolkit;
using ICSharpCode.Reporting.Addin.Globals;
using ICSharpCode.Reporting.Addin.ReportWizard.ViewModels;
@ -34,32 +36,58 @@ namespace ICSharpCode.Reporting.Addin.ReportWizard.Dialog @@ -34,32 +36,58 @@ namespace ICSharpCode.Reporting.Addin.ReportWizard.Dialog
this.context = new PushModelContext();
cboType.ItemsSource = GlobalLists.DataTypeList();
var definitions = GetTypeDefinitions();
if (definitions.Any()) {
_cboTypes.Visibility = System.Windows.Visibility.Visible;
_availTxt.Visibility = System.Windows.Visibility.Visible;
_cboTypes.ItemsSource = definitions;
_cboTypes.SelectedIndex = 0;
Projects = GetProjects();
_projectsCbo.ItemsSource = Projects;
}
IProject SelectedProject {get;set;}
IModelCollection<IProject> GetProjects(){
var solution = SharpDevelop.SD.ProjectService.CurrentSolution;
return solution.Projects;
}
IEnumerable<ITypeDefinition> GetTypeDefinitions(){
if (SelectedProject != null) {
var compilation = SharpDevelop.SD.ParserService.GetCompilation(SelectedProject);
var definitions = compilation.MainAssembly.TopLevelTypeDefinitions.Where(x => x.Properties.Any());
return definitions;
} else {
var data = new AbstractColumn("MyColumn", typeof(string));
items.Add(data);
_projTxt.Text = ResourceService.GetString("SharpReport.Wizard.PushModel.NoProject");
return null;
}
}
static IEnumerable<ITypeDefinition> GetTypeDefinitions()
{
var currentProject = SharpDevelop.SD.ProjectService.CurrentProject;
var compilation = SharpDevelop.SD.ParserService.GetCompilation(currentProject);
var definitions = compilation.MainAssembly.TopLevelTypeDefinitions.Where(x => x.Properties.Any());
return definitions;
public IModelCollection<IProject> Projects {get; private set;}
#region SolutionCombo
void _pro_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e){
SelectedProject = (IProject)e.AddedItems[0];
var definitions = GetTypeDefinitions();
// if (definitions != null) {
if (definitions.Any()) {
_cboTypes.Visibility = System.Windows.Visibility.Visible;
_availTxt.Visibility = System.Windows.Visibility.Visible;
_projTxt.Visibility = System.Windows.Visibility.Visible;
_cboTypes.ItemsSource = definitions;
_cboTypes.SelectedIndex = 0;
} else {
var data = new AbstractColumn("MyColumn", typeof(string));
items.Add(data);
_projTxt.Text = ResourceService.GetString("SharpReport.Wizard.PushModel.NoProject");
}
// }
}
#endregion
#region Combo
#region Classes Combo
void _cboTypes_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e){
var typeDefinition = (ITypeDefinition)e.AddedItems[0];
var itemsList = CreateItemsSource(typeDefinition);
if (itemsList.Count > 0) {
@ -93,6 +121,7 @@ namespace ICSharpCode.Reporting.Addin.ReportWizard.Dialog @@ -93,6 +121,7 @@ namespace ICSharpCode.Reporting.Addin.ReportWizard.Dialog
public WizardPageType ReportPageType {
get {return WizardPageType.PushModelPage;}
}
#endregion
}

Loading…
Cancel
Save