Skip to content

Commit

Permalink
Add installed package UI in Preferences TAB (#11750)
Browse files Browse the repository at this point in the history
* update

* update

* update

* update

* Update InstalledPackagesControl.xaml

* Update icons and icon sizes.

* More tweaking..

* More tweaking.
Remove delete button.
Restore delete button in context menu.

* More tweaking

* MergeFixes

* Some more tweaks

* Add contest menu style

* update colors

* More context menu tweaking.

* One small tweak.

* add mark for uninstall label

* simplify control

* Update DynamoModern.xaml

* Change ListBox to ItemsControl

* More tweaks

* More tweaks

* Restore Scollbar

* Remove unused icon

* align content with header and remove border

* update

* update menu icon

* Update InstalledPackagesControl.xaml.cs

* Fix Colors

* Move style

* Use FlatIconButtonStyle

* Update comment and use nameof()

* Update comment.

Co-authored-by: pinzart <[email protected]>
Co-authored-by: Jorgen Dahl <[email protected]>
  • Loading branch information
3 people authored Jun 28, 2021
1 parent 66818b7 commit 2fbc0da
Show file tree
Hide file tree
Showing 11 changed files with 455 additions and 10 deletions.
262 changes: 262 additions & 0 deletions src/DynamoCoreWpf/Controls/InstalledPackagesControl.xaml

Large diffs are not rendered by default.

45 changes: 45 additions & 0 deletions src/DynamoCoreWpf/Controls/InstalledPackagesControl.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
using Dynamo.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
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.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace Dynamo.Wpf.Controls
{
/// <summary>
/// Interaction logic for InstalledPackagesControl.xaml
/// </summary>
public partial class InstalledPackagesControl : UserControl
{
public InstalledPackagesControl()
{
InitializeComponent();
}

private void MoreButton_OnClick(object sender, RoutedEventArgs e)
{
var button = (Button)sender;
button.ContextMenu.DataContext = button.DataContext;
button.ContextMenu.IsOpen = true;
}

private void Expander_Expanded(object sender, RoutedEventArgs e)
{
Expander exp = (Expander)sender;
if (exp.DataContext is PackageViewModel pm)
{
pm.ToggleTypesVisibleInManagerCommand.Execute();
}
}
}
}
12 changes: 11 additions & 1 deletion src/DynamoCoreWpf/DynamoCoreWpf.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,9 @@
<Reference Include="WindowsBase" />
</ItemGroup>
<ItemGroup>
<Compile Include="Controls\InstalledPackagesControl.xaml.cs">
<DependentUpon>InstalledPackagesControl.xaml</DependentUpon>
</Compile>
<Compile Include="Controls\NodeAutoCompleteSearchControl.xaml.cs">
<DependentUpon>NodeAutoCompleteSearchControl.xaml</DependentUpon>
</Compile>
Expand Down Expand Up @@ -427,6 +430,10 @@
<Compile Include="Windows\ModelessChildWindow.cs" />
</ItemGroup>
<ItemGroup>
<Page Include="Controls\InstalledPackagesControl.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Controls\NodeAutoCompleteSearchControl.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
Expand Down Expand Up @@ -1258,7 +1265,7 @@
<ProjectReference Include="..\Libraries\PythonNodeModels\PythonNodeModels.csproj">
<Project>{8872CA17-C10D-43B9-8393-5C5A57065EB0}</Project>
<Name>PythonNodeModels</Name>
<Private>False</Private>
<Private>False</Private>
</ProjectReference>
<ProjectReference Include="..\Libraries\VMDataBridge\VMDataBridge.csproj">
<Project>{ccb6e56b-2da1-4eba-a1f9-e8510e129d12}</Project>
Expand Down Expand Up @@ -1304,6 +1311,9 @@
<Resource Include="UI\Images\profile_normal.png" />
</ItemGroup>
<ItemGroup>
<Resource Include="UI\Images\menu_16_16.png" />
<Resource Include="UI\Images\caret_down.png" />
<Resource Include="UI\Images\caret_up.png" />
<Resource Include="UI\Images\PackageManager\close_16_16.png" />
<Resource Include="UI\Images\PackageManager\down_16_16.png" />
<Resource Include="UI\Images\PackageManager\folder_16_16.png" />
Expand Down
Binary file added src/DynamoCoreWpf/UI/Images/caret_down.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/DynamoCoreWpf/UI/Images/caret_up.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/DynamoCoreWpf/UI/Images/menu.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/DynamoCoreWpf/UI/Images/menu_16_16.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
117 changes: 113 additions & 4 deletions src/DynamoCoreWpf/UI/Themes/Modern/DynamoModern.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -2293,7 +2293,6 @@
<SolidColorBrush x:Key="SemiTransparent"
Color="#80000000" />


<!--Usual button color for the Preferences Window-->
<Color x:Key="PreferencesToogleCheckedColor" R="6" G="150" B="215" A="255"/>

Expand Down Expand Up @@ -2421,7 +2420,55 @@
</Setter>
</Style>

<ControlTemplate x:Key="ExpanderToggleButton" TargetType="{x:Type ToggleButton}">
<SolidColorBrush x:Key="ExpanderCaretToggleButtonBackground" Color="#4d4d4d"/>
<SolidColorBrush x:Key="ExpanderCaretToggleButtonSelectedBackground" Color="#3c3c3c"/>

<ControlTemplate x:Key="ExpanderCaretToggleButton" TargetType="{x:Type ToggleButton}">
<Border Name="Border"
Grid.Row="0"
Background="{StaticResource ExpanderCaretToggleButtonBackground}"
BorderThickness="1"
CornerRadius="1" >
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<Image x:Name="Caret"
Grid.Column="0"
Source="pack://application:,,,/DynamoCoreWpf;component/UI/Images/Caret_Down.png"
Width="16"
Height="16"
Margin="5,10,0,10"
HorizontalAlignment="Left"
VerticalAlignment="Center"
>
</Image>
<ContentPresenter x:Name="HeaderContent"
Grid.Column="0"
Margin="0,0,0,0"
RecognizesAccessKey="True"
VerticalAlignment="Center"
Width="{Binding
RelativeSource={RelativeSource
Mode=FindAncestor,
AncestorType={x:Type Expander}},
Path=ActualWidth}"/>
</Grid>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsChecked" Value="true">
<!--Sets the icon on the expander to caret up (-)-->
<Setter Property="Background" TargetName="Border" Value="{StaticResource ExpanderCaretToggleButtonSelectedBackground}"/>
<Setter TargetName="Caret" Property="Source" Value="pack://application:,,,/DynamoCoreWpf;component/UI/Images/Caret_Up.png" />
</Trigger>
<Trigger Property="IsChecked" Value="false">
<Setter Property="Background" TargetName="Border" Value="{StaticResource ExpanderCaretToggleButtonBackground}"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>

<ControlTemplate x:Key="ExpanderPlusToggleButton" TargetType="{x:Type ToggleButton}">
<Border Name="Border"
Grid.Row="0"
Background="{StaticResource SecondaryGray}"
Expand Down Expand Up @@ -2477,6 +2524,68 @@
</TextBlock>
</DataTemplate>


<Style TargetType="Expander" x:Key="InstalledPackagesExpanderStyle">
<Setter Property="Template">
<Setter.Value>
<!-- Control template for expander -->
<ControlTemplate TargetType="Expander" x:Name="exp">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Name="ContentRow" Height="0"/>
</Grid.RowDefinitions>
<Border Name="Border" Grid.Row="0" Background="{x:Null}" BorderBrush="{x:Null}" BorderThickness="1" CornerRadius="0,0,0,0">
<ToggleButton IsChecked="{Binding Path=IsExpanded,Mode=TwoWay,RelativeSource={RelativeSource TemplatedParent}}" Template="{StaticResource ExpanderCaretToggleButton}">
<ToggleButton.Content>
<ContentPresenter ContentSource="Header" OverridesDefaultStyle="True" RecognizesAccessKey="True" />
</ToggleButton.Content>
</ToggleButton>
</Border>
<Border x:Name="Content"
Grid.Row="1"
BorderThickness="1,0,1,1"
CornerRadius="0,0,4,4" >
<!--The Margin is necesary so that the Content is perfectly aligned with the Header-->
<ContentPresenter Margin="1,-3,1,0" />
</Border>
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="IsExpanded" Value="True">
<Setter TargetName="ContentRow" Property="Height" Value="{Binding ElementName=Content,Path=Height}" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>

<Style TargetType="{x:Type ContextMenu}" x:Key="ContextMenuNoLeftColumnStyle">
<Setter Property="SnapsToDevicePixels" Value="True" />
<Setter Property="OverridesDefaultStyle" Value="True" />
<Setter Property="Grid.IsSharedSizeScope" Value="true" />
<Setter Property="HasDropShadow" Value="True" />
<Setter Property="Foreground" Value="{StaticResource PreferencesWindowFontColor}"/>
<Setter Property="Background" Value="{StaticResource PreferencesWindowItemDarkerBackgroundColor}"/>
<Setter Property="FontSize" Value="10"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ContextMenu}">
<Border x:Name="Border" Background="{StaticResource PreferencesWindowItemDarkerBackgroundColor}" BorderThickness="1">
<ItemsPresenter />
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
<Setter Property="ItemsPanel">
<Setter.Value>
<ItemsPanelTemplate>
<StackPanel Margin="-25,0,0,0"/>
</ItemsPanelTemplate>
</Setter.Value>
</Setter>
</Style>

<Style TargetType="Expander" x:Key="MenuExpanderStyle">
<Setter Property="Background" Value="{StaticResource SecondaryGray}"/>
<Setter Property="Foreground" Value="{StaticResource PreferencesWindowFontColor}"/>
Expand All @@ -2491,7 +2600,7 @@
<RowDefinition Name="ContentRow" Height="0"/>
</Grid.RowDefinitions>
<Border Name="Border" Grid.Row="0" Background="{x:Null}" BorderBrush="{x:Null}" BorderThickness="1" CornerRadius="0,0,0,0">
<ToggleButton IsChecked="{Binding Path=IsExpanded,Mode=TwoWay,RelativeSource={RelativeSource TemplatedParent}}" OverridesDefaultStyle="True" Template="{StaticResource ExpanderToggleButton}" Background="#FF4682B4">
<ToggleButton IsChecked="{Binding Path=IsExpanded,Mode=TwoWay,RelativeSource={RelativeSource TemplatedParent}}" OverridesDefaultStyle="True" Template="{StaticResource ExpanderPlusToggleButton}" Background="#FF4682B4">
<ToggleButton.Content>
<ContentPresenter ContentSource="Header" RecognizesAccessKey="True" />
</ToggleButton.Content>
Expand Down Expand Up @@ -2532,7 +2641,7 @@
<RowDefinition Name="ContentRow" Height="0"/>
</Grid.RowDefinitions>
<Border Name="Border" Grid.Row="0" Background="{x:Null}" BorderBrush="{x:Null}" BorderThickness="1" CornerRadius="0,0,0,0">
<ToggleButton IsChecked="{Binding Path=IsExpanded,Mode=TwoWay,RelativeSource={RelativeSource TemplatedParent}}" OverridesDefaultStyle="True" Template="{StaticResource ExpanderToggleButton}" Background="#FF4682B4">
<ToggleButton IsChecked="{Binding Path=IsExpanded,Mode=TwoWay,RelativeSource={RelativeSource TemplatedParent}}" OverridesDefaultStyle="True" Template="{StaticResource ExpanderPlusToggleButton}" Background="#FF4682B4">
<ToggleButton.Content>
<ContentPresenter ContentSource="Header" RecognizesAccessKey="True" />
</ToggleButton.Content>
Expand Down
9 changes: 9 additions & 0 deletions src/DynamoCoreWpf/ViewModels/Menu/PreferencesViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ public class PreferencesViewModel : ViewModelBase, INotifyPropertyChanged
private DynamoViewModel dynamoViewModel;
private bool isWarningEnabled;
private GeometryScalingOptions optionsGeometryScale = null;

private InstalledPackagesViewModel installedPackagesViewModel;
#endregion Private Properties

public GeometryScaleSize ScaleSize { get; set; }
Expand Down Expand Up @@ -142,6 +144,11 @@ public bool PreferencesDebugMode
}
}

/// <summary>
/// Returns all installed packages
/// </summary>
public ObservableCollection<PackageViewModel> LocalPackages => installedPackagesViewModel.LocalPackages;

//This includes all the properties that can be set on the General tab
#region General Properties
/// <summary>
Expand Down Expand Up @@ -697,6 +704,8 @@ public PreferencesViewModel(DynamoViewModel dynamoViewModel)
this.runPreviewEnabled = dynamoViewModel.HomeSpaceViewModel.RunSettingsViewModel.RunButtonEnabled;
this.homeSpace = dynamoViewModel.HomeSpace;
this.dynamoViewModel = dynamoViewModel;
this.installedPackagesViewModel = new InstalledPackagesViewModel(dynamoViewModel,
dynamoViewModel.PackageManagerClientViewModel.PackageManagerExtension.PackageLoader);

PythonEnginesList = new ObservableCollection<string>();
PythonEnginesList.Add(Wpf.Properties.Resources.DefaultPythonEngineNone);
Expand Down
12 changes: 7 additions & 5 deletions src/DynamoCoreWpf/Views/Menu/PreferencesView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,13 @@
xmlns:sys="clr-namespace:System;assembly=mscorlib"
xmlns:fa="http://schemas.fontawesome.io/icons/"
xmlns:packagemanager="clr-namespace:Dynamo.Wpf.Views.PackageManager"
xmlns:wpfControls="clr-namespace:Dynamo.Wpf.Controls"
WindowStartupLocation="CenterOwner"
WindowStyle="None"
ResizeMode="NoResize"
mc:Ignorable="d"
Height="474"
Width="530" >
Width="650"
ResizeMode="NoResize">

<!--Using the Styles from the SharedResourcesDictionary located in DynamoCoreWpf/UI/Themes/DynamoModern.xaml-->
<Window.Resources>
Expand Down Expand Up @@ -745,11 +746,12 @@
<!--This Grid row contains the Installed Packages section-->
<Expander x:Name="InstalledPackagesExpander"
Style="{StaticResource MenuExpanderStyle}"
IsExpanded="{Binding PreferencesTabs[Features].ExpanderActive, Converter={StaticResource ExpandersBindingConverter}, ConverterParameter=InstalledPackagesExpander}"
IsExpanded="{Binding PreferencesTabs[Features].ExpanderActive, Converter={StaticResource ExpandersBindingConverter}, ConverterParameter=InstalledPackagesExpander}"
Grid.Row="1"
Header="{x:Static p:Resources.InstalledPackageViewTitle}">
<StackPanel Orientation="Vertical" Margin="0,6,0,0">
<Label>SOME CONTENT</Label>
<StackPanel
Orientation="Vertical" Margin="0,6,0,0">
<wpfControls:InstalledPackagesControl Height="Auto"/>
</StackPanel>
</Expander>
</Grid>
Expand Down
8 changes: 8 additions & 0 deletions src/DynamoPackages/Package.cs
Original file line number Diff line number Diff line change
Expand Up @@ -489,6 +489,10 @@ internal void MarkForUninstall(IPreferences prefs)
{
PackageState = PackageStates.PendingUnload;
}
else
{
RaisePropertyChanged(nameof(EnableOldMarkedForUnistallState));
}

if (!prefs.PackageDirectoriesToUninstall.Contains(RootDirectory))
{
Expand All @@ -505,6 +509,10 @@ internal void UnmarkForUninstall(IPreferences prefs)
// Or maybe state should only be set when trying to Load the package...not here.
PackageState = PackageStates.Loaded;
}
else
{
RaisePropertyChanged(nameof(EnableOldMarkedForUnistallState));
}
prefs.PackageDirectoriesToUninstall.RemoveAll(x => x.Equals(RootDirectory));
}

Expand Down

0 comments on commit 2fbc0da

Please sign in to comment.