Browse Source

First rework of AddInManager UI showing all views and repositories VS-like in a tree view rather than in a TabControl and ComboBoxes.

pull/32/head
Andreas Weizel 13 years ago
parent
commit
57eed77d5b
  1. 143
      src/AddIns/Misc/AddInManager2/Project/Src/View/AddInManagerView.xaml
  2. 4
      src/AddIns/Misc/AddInManager2/Project/Src/View/AddInsView.xaml
  3. 60
      src/AddIns/Misc/AddInManager2/Project/Src/ViewModel/AddInManagerViewModel.cs
  4. 32
      src/AddIns/Misc/AddInManager2/Project/Src/ViewModel/AddInsViewModelBase.cs

143
src/AddIns/Misc/AddInManager2/Project/Src/View/AddInManagerView.xaml

@ -1,9 +1,10 @@
<Window <Window
x:Class="ICSharpCode.AddInManager2.View.AddInManagerView" x:Class="ICSharpCode.AddInManager2.View.AddInManagerView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:core="clr-namespace:ICSharpCode.Core.Presentation;assembly=ICSharpCode.Core.Presentation" xmlns:core="clr-namespace:ICSharpCode.Core.Presentation;assembly=ICSharpCode.Core.Presentation"
xmlns:aimview="clr-namespace:ICSharpCode.AddInManager2.View" xmlns:aimview="clr-namespace:ICSharpCode.AddInManager2.View"
xmlns:aimvm="clr-namespace:ICSharpCode.AddInManager2.ViewModel" xmlns:aimvm="clr-namespace:ICSharpCode.AddInManager2.ViewModel"
xmlns:model="clr-namespace:ICSharpCode.AddInManager2.Model"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Height="480" Height="480"
Width="640" Width="640"
@ -39,24 +40,56 @@
</Style.Triggers> </Style.Triggers>
</Style> </Style>
<Style x:Key="tabHeaderTextStyle" TargetType="{x:Type TextBlock}"> <Style x:Key="expanderHeaderTextStyle" TargetType="{x:Type TextBlock}">
<Style.Triggers> <Style.Triggers>
<DataTrigger Binding="{Binding DataContext.HasHighlightCount}" Value="True"> <DataTrigger Binding="{Binding IsExpandedInView}" Value="True">
<Setter Property="Background" Value="{x:Static SystemColors.HighlightBrush}" />
<Setter Property="Foreground" Value="{x:Static SystemColors.HighlightTextBrush}" />
</DataTrigger>
<DataTrigger Binding="{Binding HasHighlightCount}" Value="True">
<Setter Property="FontWeight" Value="Bold" /> <Setter Property="FontWeight" Value="Bold" />
</DataTrigger> </DataTrigger>
</Style.Triggers> </Style.Triggers>
<Setter Property="Text" Value="{Binding DataContext.TitleWithHighlight}" /> <Setter Property="Text" Value="{Binding TitleWithHighlight}" />
</Style> </Style>
<DataTemplate x:Key="tabItemHeaderTemplate"> <DataTemplate x:Key="expanderHeaderTemplate">
<Grid> <Grid>
<TextBlock Style="{StaticResource tabHeaderTextStyle}" /> <TextBlock Style="{StaticResource expanderHeaderTextStyle}" />
</Grid> </Grid>
</DataTemplate> </DataTemplate>
<Style TargetType="{x:Type TabItem}"> <DataTemplate x:Key="packageRepositoryItemTemplate" DataType="{x:Type model:PackageRepository}">
<Setter Property="HeaderTemplate" Value="{Binding Source={StaticResource tabItemHeaderTemplate}}" /> <TextBlock Text="{Binding Path=NameWithHighlight}">
</Style> <TextBlock.Style>
<Style TargetType="TextBlock">
<Style.Triggers>
<DataTrigger Binding="{Binding HasHighlightCount}" Value="True">
<Setter Property="FontWeight" Value="Bold" />
</DataTrigger>
</Style.Triggers>
</Style>
</TextBlock.Style>
</TextBlock>
</DataTemplate>
<DataTemplate x:Key="viewModelExpanderItemTemplate" DataType="{x:Type aimvm:AddInsViewModelBase}">
<Expander
Header="{Binding}"
HeaderTemplate="{StaticResource expanderHeaderTemplate}"
IsExpanded="{Binding IsExpandedInView}"
Margin="0,0,0,10">
<ListBox
ItemsSource="{Binding PackageRepositories}"
ItemTemplate="{StaticResource packageRepositoryItemTemplate}"
SelectedItem="{Binding Path=SelectedPackageSource}"
BorderThickness="0"
Background="Transparent"
Margin="3,0,0,0"
ScrollViewer.HorizontalScrollBarVisibility="Hidden"
/>
</Expander>
</DataTemplate>
</Window.Resources> </Window.Resources>
<Window.DataContext> <Window.DataContext>
@ -67,55 +100,59 @@
<Binding Path="Title"/> <Binding Path="Title"/>
</Window.Title> </Window.Title>
<DockPanel x:Name="MainPanel"> <Grid x:Name="MainPanel">
<Grid <Grid.ColumnDefinitions>
DockPanel.Dock="Bottom" <ColumnDefinition Width=".3*" />
Margin="4, 4"> <ColumnDefinition Width="*" />
<Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/> <ItemsControl
<ColumnDefinition Width="Auto"/> x:Name="viewNavigationList"
</Grid.ColumnDefinitions> Grid.Column="0"
<StackPanel> ItemsSource="{Binding ViewModels}"
<Image ItemTemplate="{StaticResource viewModelExpanderItemTemplate}"
Margin="3,3,3,3">
</ItemsControl>
<DockPanel x:Name="ContentPanel" Grid.Column="1">
<Grid
DockPanel.Dock="Bottom"
Margin="4, 4">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<StackPanel>
<Image
Margin="4, 4"
Style="{StaticResource errorImageStyle}" />
</StackPanel>
<TextBlock
Grid.Column="1"
Margin="4, 4" Margin="4, 4"
Style="{StaticResource errorImageStyle}" /> TextTrimming="CharacterEllipsis"
</StackPanel> Text="{Binding Path=Message}"/>
<TextBlock <Button
Grid.Column="1" Grid.Column="2"
Margin="4, 4" Content="{core:Localize Global.CloseButtonText}"
TextTrimming="CharacterEllipsis" IsCancel="True"/>
Text="{Binding Path=Message}"/> </Grid>
<Button
Grid.Column="2" <Grid x:Name="contentAreaGrid">
Content="{core:Localize Global.CloseButtonText}"
IsCancel="True"/>
</Grid>
<TabControl>
<TabItem>
<TabItem.Header>
<TextBlock Style="{StaticResource tabHeaderTextStyle}" DataContext="{Binding InstalledAddInsViewModel}" />
</TabItem.Header>
<aimview:AddInsView <aimview:AddInsView
x:Name="InstalledPackagesView" x:Name="InstalledPackagesView"
DataContext="{Binding InstalledAddInsViewModel}" /> DataContext="{Binding InstalledAddInsViewModel}"
</TabItem> Visibility="{Binding IsExpandedInView, Converter={StaticResource BoolToVisibility}}" />
<TabItem>
<TabItem.Header>
<TextBlock Style="{StaticResource tabHeaderTextStyle}" DataContext="{Binding UpdatedAddInsViewModel}" />
</TabItem.Header>
<aimview:AddInsView <aimview:AddInsView
x:Name="PackageUpdatesView" x:Name="PackageUpdatesView"
DataContext="{Binding UpdatedAddInsViewModel}" /> DataContext="{Binding UpdatedAddInsViewModel}"
</TabItem> Visibility="{Binding IsExpandedInView, Converter={StaticResource BoolToVisibility}}" />
<TabItem>
<TabItem.Header>
<TextBlock Style="{StaticResource tabHeaderTextStyle}" DataContext="{Binding AvailableAddInsViewModel}" />
</TabItem.Header>
<aimview:AddInsView <aimview:AddInsView
x:Name="AvailablePackagesView" x:Name="AvailablePackagesView"
DataContext="{Binding AvailableAddInsViewModel}" /> DataContext="{Binding AvailableAddInsViewModel}"
</TabItem> Visibility="{Binding IsExpandedInView, Converter={StaticResource BoolToVisibility}}" />
</TabControl> </Grid>
</DockPanel> </DockPanel>
</Grid>
</Window> </Window>

4
src/AddIns/Misc/AddInManager2/Project/Src/View/AddInsView.xaml

@ -491,7 +491,7 @@
<RowDefinition Height="Auto"/> <RowDefinition Height="Auto"/>
</Grid.RowDefinitions> </Grid.RowDefinitions>
<TextBlock <!-- <TextBlock
Grid.Row="0" Grid.Row="0"
Grid.Column="0" Grid.Column="0"
VerticalAlignment="Center" VerticalAlignment="Center"
@ -507,7 +507,7 @@
SelectedItem="{Binding Path=SelectedPackageSource}" SelectedItem="{Binding Path=SelectedPackageSource}"
ItemsSource="{Binding Path=PackageRepositories}" ItemsSource="{Binding Path=PackageRepositories}"
ItemTemplate="{StaticResource PackageSourceComboBoxItemTemplate}" ItemTemplate="{StaticResource PackageSourceComboBoxItemTemplate}"
Visibility="{Binding Path=ShowPackageRepositories, Converter={StaticResource BoolToVisibility}}"/> Visibility="{Binding Path=ShowPackageRepositories, Converter={StaticResource BoolToVisibility}}"/>-->
<TextBlock <TextBlock
Grid.Row="1" Grid.Row="1"

60
src/AddIns/Misc/AddInManager2/Project/Src/ViewModel/AddInManagerViewModel.cs

@ -4,8 +4,10 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
using System.ComponentModel;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using ICSharpCode.AddInManager2.Model; using ICSharpCode.AddInManager2.Model;
using ICSharpCode.AddInManager2.View; using ICSharpCode.AddInManager2.View;
using ICSharpCode.Core; using ICSharpCode.Core;
@ -20,6 +22,8 @@ namespace ICSharpCode.AddInManager2.ViewModel
private string _message; private string _message;
private bool _hasError; private bool _hasError;
private ObservableCollection<AddInsViewModelBase> _viewModels;
public AddInManagerViewModel() public AddInManagerViewModel()
: base() : base()
{ {
@ -42,10 +46,25 @@ namespace ICSharpCode.AddInManager2.ViewModel
AddInManager.Events.AddInOperationError += AddInManager_Events_AddInOperationError; AddInManager.Events.AddInOperationError += AddInManager_Events_AddInOperationError;
AddInManager.Events.AcceptLicenses += AddInManager_Events_AcceptLicenses; AddInManager.Events.AcceptLicenses += AddInManager_Events_AcceptLicenses;
AvailableAddInsViewModel = new AvailableAddInsViewModel(); _viewModels = new ObservableCollection<AddInsViewModelBase>();
// Create and collect the models
InstalledAddInsViewModel = new InstalledAddInsViewModel(); InstalledAddInsViewModel = new InstalledAddInsViewModel();
AvailableAddInsViewModel = new AvailableAddInsViewModel();
UpdatedAddInsViewModel = new UpdatedAddInsViewModel(); UpdatedAddInsViewModel = new UpdatedAddInsViewModel();
_viewModels.Add(InstalledAddInsViewModel);
_viewModels.Add(AvailableAddInsViewModel);
_viewModels.Add(UpdatedAddInsViewModel);
foreach (var viewModel in _viewModels)
{
viewModel.PropertyChanged += ViewModel_PropertyChanged;
}
// Expand the first view
InstalledAddInsViewModel.IsExpandedInView = true;
// Read the packages // Read the packages
AvailableAddInsViewModel.ReadPackages(); AvailableAddInsViewModel.ReadPackages();
InstalledAddInsViewModel.ReadPackages(); InstalledAddInsViewModel.ReadPackages();
@ -70,6 +89,14 @@ namespace ICSharpCode.AddInManager2.ViewModel
private set; private set;
} }
public ObservableCollection<AddInsViewModelBase> ViewModels
{
get
{
return _viewModels;
}
}
public string Title public string Title
{ {
// get { return viewTitle.Title; } // get { return viewTitle.Title; }
@ -82,6 +109,10 @@ namespace ICSharpCode.AddInManager2.ViewModel
AddInManager.Events.OperationStarted -= AddInManager_Events_OperationStarted; AddInManager.Events.OperationStarted -= AddInManager_Events_OperationStarted;
AddInManager.Events.AddInOperationError -= AddInManager_Events_AddInOperationError; AddInManager.Events.AddInOperationError -= AddInManager_Events_AddInOperationError;
AddInManager.Events.AcceptLicenses -= AddInManager_Events_AcceptLicenses; AddInManager.Events.AcceptLicenses -= AddInManager_Events_AcceptLicenses;
foreach (var viewModel in _viewModels)
{
viewModel.PropertyChanged -= ViewModel_PropertyChanged;
}
} }
private void ShowErrorMessage(string message) private void ShowErrorMessage(string message)
@ -153,5 +184,32 @@ namespace ICSharpCode.AddInManager2.ViewModel
view.Owner = SD.Workbench.MainWindow; view.Owner = SD.Workbench.MainWindow;
return view.ShowDialog() ?? false; return view.ShowDialog() ?? false;
} }
private void ViewModel_PropertyChanged(object sender, PropertyChangedEventArgs e)
{
if (e.PropertyName == "IsExpandedInView")
{
AddInsViewModelBase expandedViewModel = sender as AddInsViewModelBase;
if (expandedViewModel != null)
{
if (expandedViewModel.IsExpandedInView)
{
// Unexpand all view models besides this one
foreach (var viewModel in _viewModels)
{
if (viewModel != expandedViewModel)
{
viewModel.IsExpandedInView = false;
}
}
}
else if (!expandedViewModel.IsExpandedInView && (_viewModels.Count(v => v.IsExpandedInView) == 0))
{
// This is the last unexpanded view => leave it open
expandedViewModel.IsExpandedInView = true;
}
}
}
}
} }
} }

32
src/AddIns/Misc/AddInManager2/Project/Src/ViewModel/AddInsViewModelBase.cs

@ -22,6 +22,8 @@ namespace ICSharpCode.AddInManager2.ViewModel
private PackageRepository _activePackageSource; private PackageRepository _activePackageSource;
private IPackageRepository _activePackageRepository; private IPackageRepository _activePackageRepository;
private bool _isReadingPackages; private bool _isReadingPackages;
private bool _isExpandedinView;
private bool _showPackageSources;
private ObservableCollection<PackageRepository> _packageRepositories; private ObservableCollection<PackageRepository> _packageRepositories;
@ -43,6 +45,7 @@ namespace ICSharpCode.AddInManager2.ViewModel
{ {
_activePackageRepository = null; _activePackageRepository = null;
_isReadingPackages = false; _isReadingPackages = false;
_isExpandedinView = false;
// Initialization of internal lists // Initialization of internal lists
_pages = new Pages(); _pages = new Pages();
@ -235,6 +238,19 @@ namespace ICSharpCode.AddInManager2.ViewModel
} }
} }
public bool IsExpandedInView
{
get
{
return _isExpandedinView;
}
set
{
_isExpandedinView = value;
OnPropertyChanged(m => m.IsExpandedInView);
}
}
public virtual void ReadPackages() public virtual void ReadPackages()
{ {
_pages.SelectedPageNumber = 1; _pages.SelectedPageNumber = 1;
@ -424,8 +440,15 @@ namespace ICSharpCode.AddInManager2.ViewModel
public bool ShowPackageSources public bool ShowPackageSources
{ {
get; get
set; {
return _showPackageSources;
}
set
{
_showPackageSources = value;
UpdatePackageSources();
}
} }
public ObservableCollection<PackageRepository> PackageRepositories public ObservableCollection<PackageRepository> PackageRepositories
@ -438,6 +461,11 @@ namespace ICSharpCode.AddInManager2.ViewModel
private void UpdatePackageSources() private void UpdatePackageSources()
{ {
if (!ShowPackageSources)
{
return;
}
PackageRepository oldValue = SelectedPackageSource; PackageRepository oldValue = SelectedPackageSource;
// Refill package sources list // Refill package sources list

Loading…
Cancel
Save