9 changed files with 260 additions and 99 deletions
@ -1,48 +0,0 @@
@@ -1,48 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?> |
||||
<gui:OptionPanel |
||||
x:Class="ICSharpCode.VBNetBinding.OptionPanels.ProjectImportsOptions" xmlns:gui="clr-namespace:ICSharpCode.SharpDevelop.Gui;assembly=ICSharpCode.SharpDevelop" xmlns:addin="clr-namespace:ICSharpCode.VBNetBinding.OptionPanels" xmlns:sd="http://icsharpcode.net/sharpdevelop/core" 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"> |
||||
<GroupBox |
||||
Header="${res:Dialog.ProjectOptions.ProjectImports.Title}" |
||||
Grid.Column="0" |
||||
Grid.Row="0" |
||||
HorizontalAlignment="Left" |
||||
VerticalAlignment="Top"> |
||||
<Grid> |
||||
<Grid.ColumnDefinitions> |
||||
<ColumnDefinition |
||||
Width="*" /> |
||||
<ColumnDefinition |
||||
Width="Auto" /> |
||||
</Grid.ColumnDefinitions> |
||||
<ListBox |
||||
Grid.Column="0" |
||||
Grid.Row="0" |
||||
Margin="3,3,3,3" |
||||
HorizontalAlignment="Stretch" |
||||
VerticalAlignment="Stretch" /> |
||||
<widgets:StackPanelWithSpacing |
||||
SpaceBetweenItems="5" |
||||
Grid.Column="1" |
||||
Grid.Row="0" |
||||
HorizontalAlignment="Stretch" |
||||
VerticalAlignment="Stretch" |
||||
Margin="3,3,3,3"> |
||||
<Label |
||||
Content="${res:Dialog.ProjectOptions.ProjectImports.Title}" /> |
||||
<ComboBox |
||||
Height="20" |
||||
Name="namespaces" /> |
||||
<widgets:UniformGridWithSpacing> |
||||
<Button |
||||
Content="${res:Dialog.ProjectOptions.ProjectImports.AddImport}" |
||||
Name="addImport" |
||||
Click="AddImportClick" /> |
||||
<Button |
||||
Content="${res:Dialog.ProjectOptions.ProjectImports.RemoveImport}" |
||||
Name="removeImport" |
||||
Click="RemoveImportClick" /> |
||||
</widgets:UniformGridWithSpacing> |
||||
</widgets:StackPanelWithSpacing> |
||||
</Grid> |
||||
</GroupBox> |
||||
</gui:OptionPanel> |
@ -1,38 +0,0 @@
@@ -1,38 +0,0 @@
|
||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using System.Text; |
||||
using System.Windows; |
||||
using System.Windows.Controls; |
||||
using System.Windows.Data; |
||||
using System.Windows.Documents; |
||||
using System.Windows.Input; |
||||
using System.Windows.Media; |
||||
using ICSharpCode.SharpDevelop.Gui; |
||||
using ICSharpCode.SharpDevelop.Project; |
||||
|
||||
namespace ICSharpCode.VBNetBinding.OptionPanels |
||||
{ |
||||
/// <summary>
|
||||
/// Interaction logic for ProjectImportsOptions.xaml
|
||||
/// </summary>
|
||||
public partial class ProjectImportsOptions : OptionPanel |
||||
{ |
||||
public ProjectImportsOptions() |
||||
{ |
||||
InitializeComponent(); |
||||
} |
||||
|
||||
void AddImportClick(object sender, RoutedEventArgs e) |
||||
{ |
||||
|
||||
} |
||||
|
||||
void RemoveImportClick(object sender, RoutedEventArgs e) |
||||
{ |
||||
|
||||
} |
||||
} |
||||
} |
@ -0,0 +1,75 @@
@@ -0,0 +1,75 @@
|
||||
<?xml version="1.0" encoding="utf-8"?> |
||||
<optionpanels:ProjectOptionPanel |
||||
x:Class="ICSharpCode.VBNetBinding.OptionPanels.ProjectImportsXaml" |
||||
xmlns:gui="clr-namespace:ICSharpCode.SharpDevelop.Gui;assembly=ICSharpCode.SharpDevelop" |
||||
xmlns:optionpanels="clr-namespace:ICSharpCode.SharpDevelop.Gui.OptionPanels;assembly=ICSharpCode.SharpDevelop" |
||||
xmlns:addin="clr-namespace:ICSharpCode.VBNetBinding.OptionPanels" |
||||
xmlns:core="http://icsharpcode.net/sharpdevelop/core" |
||||
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"> |
||||
<ScrollViewer VerticalScrollBarVisibility="Auto" |
||||
HorizontalScrollBarVisibility="Auto" > |
||||
<GroupBox |
||||
Header="{core:Localize Dialog.ProjectOptions.ProjectImports.Title}" |
||||
HorizontalAlignment="Stretch" VerticalAlignment="Stretch"> |
||||
<Grid> |
||||
<Grid.ColumnDefinitions> |
||||
<ColumnDefinition Width="2*" /> |
||||
<ColumnDefinition Width="*" /> |
||||
</Grid.ColumnDefinitions> |
||||
|
||||
<ListBox |
||||
HorizontalAlignment="Stretch" VerticalAlignment="Stretch" |
||||
ItemsSource="{Binding ProjectItems}" |
||||
SelectedItem="{Binding SelectedProjectItem}"> |
||||
</ListBox> |
||||
|
||||
<Grid Grid.Column="1" Grid.ColumnSpan="2" Margin="3,0,3,0" |
||||
HorizontalAlignment="Stretch"> |
||||
<Grid.ColumnDefinitions> |
||||
<ColumnDefinition></ColumnDefinition> |
||||
<ColumnDefinition></ColumnDefinition> |
||||
</Grid.ColumnDefinitions> |
||||
<Grid.RowDefinitions> |
||||
<RowDefinition></RowDefinition> |
||||
<RowDefinition></RowDefinition> |
||||
<RowDefinition></RowDefinition> |
||||
<RowDefinition></RowDefinition> |
||||
<RowDefinition></RowDefinition> |
||||
<RowDefinition></RowDefinition> |
||||
<RowDefinition></RowDefinition> |
||||
<RowDefinition></RowDefinition> |
||||
</Grid.RowDefinitions> |
||||
|
||||
<Label Grid.ColumnSpan="2" |
||||
HorizontalAlignment="Left" VerticalAlignment="Center" |
||||
Content="{core:Localize Dialog.ProjectOptions.ProjectImports.Namespace}" /> |
||||
|
||||
<ComboBox Grid.Row="1" Grid.ColumnSpan="2" |
||||
VerticalAlignment="Center" |
||||
ItemsSource="{Binding NameSpaceItems}" |
||||
SelectedItem="{Binding SelectedNameSpace}" |
||||
></ComboBox> |
||||
|
||||
<Button Grid.Row="2" |
||||
Content="{core:Localize Dialog.ProjectOptions.ProjectImports.AddImport}" |
||||
Style="{x:Static core:GlobalStyles.ButtonStyle}" |
||||
IsEnabled="{Binding AddButtonEnable}" |
||||
HorizontalAlignment="Stretch" |
||||
VerticalAlignment="Center" |
||||
Click="AddButton_Click"> |
||||
</Button> |
||||
|
||||
<Button Grid.Row="3" |
||||
Content="{core:Localize Dialog.ProjectOptions.ProjectImports.RemoveImport}" |
||||
Style="{x:Static core:GlobalStyles.ButtonStyle}" |
||||
IsEnabled="{Binding RemoveButtonEnable}" |
||||
HorizontalAlignment="Stretch" |
||||
VerticalAlignment="Center" |
||||
Click="RemoveButton_Click"></Button> |
||||
</Grid> |
||||
</Grid> |
||||
</GroupBox> |
||||
</ScrollViewer> |
||||
</optionpanels:ProjectOptionPanel> |
@ -0,0 +1,171 @@
@@ -0,0 +1,171 @@
|
||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using System.Collections.ObjectModel; |
||||
using System.Text; |
||||
using System.Windows; |
||||
using System.Windows.Controls; |
||||
using System.Windows.Data; |
||||
using System.Windows.Documents; |
||||
using System.Windows.Input; |
||||
using System.Windows.Media; |
||||
using System.Linq; |
||||
using ICSharpCode.SharpDevelop; |
||||
using ICSharpCode.SharpDevelop.Dom; |
||||
using ICSharpCode.SharpDevelop.Gui; |
||||
using ICSharpCode.SharpDevelop.Gui.OptionPanels; |
||||
using ICSharpCode.SharpDevelop.Project; |
||||
|
||||
namespace ICSharpCode.VBNetBinding.OptionPanels |
||||
{ |
||||
/// <summary>
|
||||
/// Interaction logic for ProjectImportsOptions.xaml
|
||||
/// </summary>
|
||||
public partial class ProjectImportsXaml : ProjectOptionPanel |
||||
{ |
||||
|
||||
public ProjectImportsXaml() |
||||
{ |
||||
InitializeComponent(); |
||||
} |
||||
|
||||
protected override void Load(MSBuildBasedProject project, string configuration, string platform) |
||||
{ |
||||
base.Load(project, configuration, platform); |
||||
Initialize(); |
||||
} |
||||
|
||||
|
||||
protected override bool Save(MSBuildBasedProject project, string configuration, string platform) |
||||
{ |
||||
List<ProjectItem> imports = new List<ProjectItem>(); |
||||
foreach(ProjectItem item in project.Items) |
||||
{ |
||||
if(item.ItemType == ItemType.Import) |
||||
{ |
||||
imports.Add(item); |
||||
} |
||||
} |
||||
|
||||
foreach(ImportProjectItem item in imports) |
||||
{ |
||||
ProjectService.RemoveProjectItem(project, item); |
||||
} |
||||
|
||||
foreach(string importedNamespace in ProjectItems) |
||||
{ |
||||
ProjectService.AddProjectItem(project, new ImportProjectItem(project, importedNamespace)); |
||||
} |
||||
|
||||
return base.Save(project, configuration, platform); |
||||
} |
||||
|
||||
private ObservableCollection<string> projectItems; |
||||
|
||||
public ObservableCollection<string> ProjectItems { |
||||
get { return projectItems; } |
||||
set { projectItems = value; |
||||
base.RaisePropertyChanged(() => ProjectItems); |
||||
} |
||||
} |
||||
|
||||
private string selectedProjectItem; |
||||
|
||||
public string SelectedProjectItem { |
||||
get { return selectedProjectItem; } |
||||
set { selectedProjectItem = value; |
||||
base.RaisePropertyChanged(() => SelectedProjectItem); |
||||
RemoveButtonEnable = true; |
||||
AddButtonEnable = false; |
||||
} |
||||
} |
||||
|
||||
private ObservableCollection <string> nameSpaceItems; |
||||
|
||||
public ObservableCollection<string> NameSpaceItems { |
||||
get { return nameSpaceItems; } |
||||
set { nameSpaceItems = value; |
||||
base.RaisePropertyChanged(() => NameSpaceItems); |
||||
} |
||||
} |
||||
|
||||
|
||||
private string selectedNameSpace; |
||||
|
||||
public string SelectedNameSpace { |
||||
get { return selectedNameSpace; } |
||||
set { selectedNameSpace = value; |
||||
base.RaisePropertyChanged(()=>SelectedNameSpace); |
||||
AddButtonEnable = true; |
||||
} |
||||
} |
||||
|
||||
|
||||
private bool addButtonEnable; |
||||
|
||||
public bool AddButtonEnable { |
||||
get { return addButtonEnable; } |
||||
set { addButtonEnable = value; |
||||
base.RaisePropertyChanged(() => AddButtonEnable); |
||||
} |
||||
} |
||||
|
||||
private bool removeButtonEnable; |
||||
|
||||
public bool RemoveButtonEnable { |
||||
get { return removeButtonEnable; } |
||||
set { removeButtonEnable = value; |
||||
base.RaisePropertyChanged(() => RemoveButtonEnable); |
||||
} |
||||
} |
||||
|
||||
private void Initialize() |
||||
{ |
||||
ProjectItems = new ObservableCollection<string>(); |
||||
NameSpaceItems = new ObservableCollection<string> (); |
||||
|
||||
foreach(ProjectItem item in base.Project.Items) |
||||
{ |
||||
if(item.ItemType == ItemType.Import) { |
||||
ProjectItems.Add(item.Include); |
||||
} |
||||
} |
||||
|
||||
|
||||
IProjectContent projectContent = ParserService.GetProjectContent(base.Project); |
||||
foreach(IProjectContent refProjectContent in projectContent.ThreadSafeGetReferencedContents()) { |
||||
AddNamespaces(refProjectContent); |
||||
} |
||||
AddNamespaces(projectContent); |
||||
} |
||||
|
||||
private void AddNamespaces(IProjectContent projectContent) |
||||
{ |
||||
foreach(string projectNamespace in projectContent.NamespaceNames) { |
||||
if (!string.IsNullOrEmpty(projectNamespace)) { |
||||
|
||||
if (!NameSpaceItems.Contains(projectNamespace)) { |
||||
NameSpaceItems.Add(projectNamespace); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
|
||||
void AddButton_Click(object sender, RoutedEventArgs e) |
||||
{ |
||||
ProjectItems.Add(SelectedNameSpace); |
||||
IsDirty = true; |
||||
} |
||||
|
||||
void RemoveButton_Click(object sender, RoutedEventArgs e) |
||||
{ |
||||
ProjectItems.Remove(SelectedProjectItem); |
||||
SelectedProjectItem = null; |
||||
RemoveButtonEnable = false; |
||||
AddButtonEnable = false; |
||||
IsDirty = true; |
||||
} |
||||
} |
||||
} |
Loading…
Reference in new issue