Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

move package search paths to preferences settings #11762

Merged
merged 25 commits into from
Jun 22, 2021
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
2e542ca
add new color for dark backgrounds
mjkkirschner Jun 11, 2021
a37047b
rename style
mjkkirschner Jun 14, 2021
91c87c7
get rid of selected index
mjkkirschner Jun 15, 2021
9952bf2
missed
mjkkirschner Jun 15, 2021
560d207
Merge branch 'master' of https://github.com/DynamoDS/Dynamo into sear…
mjkkirschner Jun 16, 2021
11aefcb
tweak some margins
mjkkirschner Jun 16, 2021
5b59f9e
new icons
mjkkirschner Jun 16, 2021
ea02e3e
expander bigger font
mjkkirschner Jun 16, 2021
4e7925c
change all expander headers to 14pt font, medium
mjkkirschner Jun 16, 2021
768e9f5
add isdisabled helper
mjkkirschner Jun 17, 2021
5530b7c
missed
mjkkirschner Jun 17, 2021
cea771d
fix tooltips
mjkkirschner Jun 17, 2021
f0c149e
add new icons
mjkkirschner Jun 17, 2021
a58d6e8
fix bug
mjkkirschner Jun 17, 2021
e52eb79
update resx
mjkkirschner Jun 17, 2021
5ec29ba
fix the build - typo
mjkkirschner Jun 17, 2021
fdfaca3
obsolete commands for raising old dialogs.
mjkkirschner Jun 18, 2021
8d0b336
missed file
mjkkirschner Jun 18, 2021
242b3b4
remove menu item from debug
mjkkirschner Jun 18, 2021
7fb292c
Merge branch 'master' into searchpathslist
mjkkirschner Jun 21, 2021
6b2a793
two small textblock and label styles
mjkkirschner Jun 21, 2021
e0a9449
Merge branch 'searchpathslist' of https://github.com/mjkkirschner/Dyn…
mjkkirschner Jun 21, 2021
f8752bb
review comments
mjkkirschner Jun 21, 2021
405a5b4
Merge branch 'master' of https://github.com/DynamoDS/Dynamo into sear…
mjkkirschner Jun 21, 2021
b79b617
fix 2 tests
mjkkirschner Jun 22, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/DynamoCoreWpf/DynamoCoreWpf.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
<Reference Include="PresentationFramework" />
<Reference Include="ProtoGeometry, Version=2.12.0.5264, Culture=neutral, processorArchitecture=AMD64">
<HintPath>..\packages\DynamoVisualProgramming.LibG_227_0_0.2.12.0.5264\lib\net48\ProtoGeometry.dll</HintPath>
<Private>False</Private>
<Private>False</Private>
</Reference>
<Reference Include="RestSharp, Version=105.2.3.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\RestSharp.105.2.3\lib\net46\RestSharp.dll</HintPath>
Expand Down Expand Up @@ -1299,6 +1299,10 @@
<Resource Include="UI\Images\profile_normal.png" />
</ItemGroup>
<ItemGroup>
<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" />
<Resource Include="UI\Images\PackageManager\up_16_16.png" />
mjkkirschner marked this conversation as resolved.
Show resolved Hide resolved
<EmbeddedResource Include="Controls\Docs\NodeAutocompleteDocumentation.html" />
<Content Include="sharpdx_direct3d11_effects_x64.dll">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
26 changes: 24 additions & 2 deletions src/DynamoCoreWpf/UI/Themes/Modern/DynamoModern.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -2266,6 +2266,8 @@

<SolidColorBrush x:Key="PreferencesWindowBackgroundColor"
Color="#535353" />
<SolidColorBrush x:Key="PreferencesWindowItemDarkerBackgroundColor"
Color="#353535"/>
<SolidColorBrush x:Key="PreferencesWindowFontColor"
Color="#E5E5E5" />
<SolidColorBrush x:Key="PreferencesWindowButtonColor"
Expand Down Expand Up @@ -2445,10 +2447,19 @@
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>


<DataTemplate x:Key="expanderHeader">
<TextBlock
Text="{Binding}"
FontSize="14"
FontWeight="Medium">
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this will probably do something once we change all the fonts to Artifakt.

</TextBlock>
</DataTemplate>

<Style TargetType="Expander" x:Key="MenuExpanderStyle">
<Setter Property="Background" Value="{StaticResource SecondaryGray}"/>
<Setter Property="Foreground" Value="{StaticResource PreferencesWindowFontColor}"/>
<Setter Property="HeaderTemplate" Value="{StaticResource expanderHeader}"/>
<Setter Property="Template">
<Setter.Value>
<!-- Control template for expander -->
Expand Down Expand Up @@ -2482,10 +2493,14 @@
</Setter>
</Style>




<!-- This expander style is similar to the MenuExpanderStyle and the only difference is the left-margin spacing -->
<Style TargetType="Expander" x:Key="WorkspaceReferencesExpanderStyle">
<Setter Property="Background" Value="{StaticResource SecondaryGray}"/>
<Setter Property="Foreground" Value="{StaticResource PreferencesWindowFontColor}"/>
<Setter Property="HeaderTemplate" Value="{StaticResource expanderHeader}"/>
<Setter Property="Template">
<Setter.Value>
<!-- Control template for expander -->
Expand Down Expand Up @@ -3223,10 +3238,17 @@
</Trigger>
</Style.Triggers>
</Style>



<!--This Style will be used for the small trash icon button that appears when a new Style is created in the Visual Settings tab-->
<Style x:Key="RemoveStyleButtonStyle"
<Style x:Key="FlatIconButtonStyle"
TargetType="{x:Type Button}">
<Style.Triggers>
<Trigger Property="IsEnabled" Value="False">
<Setter Property="Opacity" Value=".5" />
</Trigger>
</Style.Triggers>
<Setter Property="Background"
Value="Transparent"/>
<Setter Property="Template">
Expand Down
5 changes: 0 additions & 5 deletions src/DynamoCoreWpf/ViewModels/Core/DynamoViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,6 @@ internal PreferencesViewModel PreferencesViewModel
{
return preferencesViewModel;
}
set
{
preferencesViewModel = value;
RaisePropertyChanged(nameof(PreferencesViewModel));
}
}

public Point TransformOrigin
Expand Down
21 changes: 21 additions & 0 deletions src/DynamoCoreWpf/ViewModels/Menu/PreferencesViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
using Dynamo.Graph.Workspaces;
using Dynamo.Logging;
using Dynamo.Models;
using Dynamo.PackageManager;
using Dynamo.Wpf.ViewModels.Core.Converters;
using Res = Dynamo.Wpf.Properties.Resources;

Expand Down Expand Up @@ -599,6 +600,11 @@ private void AddPythonEnginesOptions()
}
#endregion

/// <summary>
/// Package Search Paths view model.
/// </summary>
public PackagePathViewModel PackagePathsViewModel { get; set; }

/// <summary>
/// The PreferencesViewModel constructor basically initialize all the ItemsSource for the corresponding ComboBox in the View (PreferencesView.xaml)
/// </summary>
Expand Down Expand Up @@ -672,6 +678,21 @@ public PreferencesViewModel(DynamoViewModel dynamoViewModel)
preferencesTabs.Add("General", new TabSettings() { Name = "General", ExpanderActive = string.Empty });
preferencesTabs.Add("Features",new TabSettings() { Name = "Features", ExpanderActive = string.Empty });
preferencesTabs.Add("VisualSettings",new TabSettings() { Name = "VisualSettings", ExpanderActive = string.Empty });
preferencesTabs.Add("Package Manager", new TabSettings() { Name = "Package Manager", ExpanderActive = string.Empty });
mjkkirschner marked this conversation as resolved.
Show resolved Hide resolved

//create a packagePathsViewModel we'll use to interact with the package search paths list.
var loadPackagesParams = new LoadPackageParams
{
Preferences = preferenceSettings,
PathManager = dynamoViewModel.Model.PathManager,
};
var customNodeManager = dynamoViewModel.Model.CustomNodeManager;
var packageLoader = dynamoViewModel.Model.GetPackageManagerExtension()?.PackageLoader;
var viewModel = new PackagePathViewModel(packageLoader, loadPackagesParams, customNodeManager);

PackagePathsViewModel = new PackagePathViewModel(packageLoader, loadPackagesParams, customNodeManager);
mjkkirschner marked this conversation as resolved.
Show resolved Hide resolved


this.PropertyChanged += Model_PropertyChanged;
}

Expand Down
123 changes: 59 additions & 64 deletions src/DynamoCoreWpf/ViewModels/PackageManager/PackagePathViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,28 +9,22 @@
using DelegateCommand = Dynamo.UI.Commands.DelegateCommand;
using Dynamo.Models;
using System.Windows.Data;
using System.Globalization;

namespace Dynamo.ViewModels
{
public sealed class PathEnabledConverter : IValueConverter
public sealed class PathEnabledConverter : IMultiValueConverter
pinzart90 marked this conversation as resolved.
Show resolved Hide resolved
{
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
{
if (value != null && parameter != null)
{
var disableStandardLibrary = (bool)parameter;
if (disableStandardLibrary)
{
var path = value as string;
return String.CompareOrdinal(path, Resources.PackagePathViewModel_Standard_Library) != 0;
}
}
return true;
var vm = values[0] as PackagePathViewModel;
var path = values[1] as string;
mjkkirschner marked this conversation as resolved.
Show resolved Hide resolved
return vm.IsPathCurrentlyDisabled(path);
}

public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
{
throw new NotSupportedException();
throw new NotImplementedException();
}
}

Expand All @@ -50,21 +44,9 @@ public class PackagePathEventArgs : EventArgs
public class PackagePathViewModel : ViewModelBase
{
public ObservableCollection<string> RootLocations { get; private set; }
private int selectedIndex;
public int SelectedIndex
{
get
{
return selectedIndex;
}
set
{
selectedIndex = value;
RaisePropertyChanged(nameof(SelectedIndex));
RaiseCanExecuteChanged();
}
}

[Obsolete("SelectedIndex is no longer referenced, do not use.")]
public int SelectedIndex { get; set; }

public event EventHandler<PackagePathEventArgs> RequestShowFileDialog;
public virtual void OnRequestShowFileDialog(object sender, PackagePathEventArgs e)
{
Expand All @@ -89,8 +71,6 @@ private IPreferences setting
public DelegateCommand UpdatePathCommand { get; private set; }
public DelegateCommand SaveSettingCommand { get; private set; }

public static bool DisableStandardLibrary = false;

public PackagePathViewModel(PackageLoader loader, LoadPackageParams loadParams, CustomNodeManager customNodeManager)
{
this.packageLoader = loader;
Expand All @@ -100,13 +80,11 @@ public PackagePathViewModel(PackageLoader loader, LoadPackageParams loadParams,
InitializeRootLocations();

AddPathCommand = new DelegateCommand(p => InsertPath());
DeletePathCommand = new DelegateCommand(p => RemovePathAt((int) p), CanDelete);
MovePathUpCommand = new DelegateCommand(p => SwapPath((int) p, ((int) p) - 1), CanMoveUp);
MovePathDownCommand = new DelegateCommand(p => SwapPath((int) p, ((int) p) + 1), CanMoveDown);
UpdatePathCommand = new DelegateCommand(p => UpdatePathAt((int) p), CanUpdate);
DeletePathCommand = new DelegateCommand(p => RemovePathAt(ConvertPathToIndex(p)), p => CanDelete(ConvertPathToIndex(p)));
MovePathUpCommand = new DelegateCommand(p => SwapPath(ConvertPathToIndex(p), ConvertPathToIndex(p) - 1), p => CanMoveUp(ConvertPathToIndex(p)));
MovePathDownCommand = new DelegateCommand(p => SwapPath(ConvertPathToIndex(p), ConvertPathToIndex(p) + 1), p => CanMoveDown(ConvertPathToIndex(p)));
UpdatePathCommand = new DelegateCommand(p => UpdatePathAt(ConvertPathToIndex(p)), p => CanUpdate(ConvertPathToIndex(p)));
SaveSettingCommand = new DelegateCommand(CommitChanges);

SelectedIndex = 0;
}
/// <summary>
/// This constructor overload has been added for backwards comptability.
Expand All @@ -118,15 +96,21 @@ public PackagePathViewModel(IPreferences setting)
InitializeRootLocations();

AddPathCommand = new DelegateCommand(p => InsertPath());
DeletePathCommand = new DelegateCommand(p => RemovePathAt((int)p), CanDelete);
MovePathUpCommand = new DelegateCommand(p => SwapPath((int)p, ((int)p) - 1), CanMoveUp);
MovePathDownCommand = new DelegateCommand(p => SwapPath((int)p, ((int)p) + 1), CanMoveDown);
UpdatePathCommand = new DelegateCommand(p => UpdatePathAt((int)p), CanUpdate);
DeletePathCommand = new DelegateCommand(p => RemovePathAt(ConvertPathToIndex(p)), p=>CanDelete(ConvertPathToIndex(p)));
MovePathUpCommand = new DelegateCommand(p => SwapPath(ConvertPathToIndex(p), ConvertPathToIndex(p)-1), p=> CanMoveUp(ConvertPathToIndex(p)));
MovePathDownCommand = new DelegateCommand(p => SwapPath(ConvertPathToIndex(p), ConvertPathToIndex(p) + 1), p => CanMoveDown(ConvertPathToIndex(p)));
UpdatePathCommand = new DelegateCommand(p => UpdatePathAt(ConvertPathToIndex(p)), p=>CanUpdate(ConvertPathToIndex(p)));
mjkkirschner marked this conversation as resolved.
Show resolved Hide resolved
SaveSettingCommand = new DelegateCommand(CommitChanges);

SelectedIndex = 0;
}

private int ConvertPathToIndex(object path)
{
if(path is int pint)
{
return pint;
}
return RootLocations.IndexOf(path as string);
}

private void RaiseCanExecuteChanged()
{
Expand All @@ -137,28 +121,29 @@ private void RaiseCanExecuteChanged()
UpdatePathCommand.RaiseCanExecuteChanged();
}

private bool CanDelete(object param)
private bool CanDelete(int param)
{
if (RootLocations.IndexOf(Resources.PackagePathViewModel_Standard_Library) == SelectedIndex)
if (RootLocations.IndexOf(Resources.PackagePathViewModel_Standard_Library) == param)
{
return false;
}
return RootLocations.Count > 1;

return RootLocations.Count > 1;
}

private bool CanMoveUp(object param)
private bool CanMoveUp(int param)
{
return SelectedIndex > 0;
return param > 0;
}

private bool CanMoveDown(object param)
private bool CanMoveDown(int param)
{
return SelectedIndex < RootLocations.Count - 1;
return param < RootLocations.Count - 1;
}

private bool CanUpdate(object param)
private bool CanUpdate(int param)
{
return RootLocations.IndexOf(Resources.PackagePathViewModel_Standard_Library) != SelectedIndex;
return RootLocations.IndexOf(Resources.PackagePathViewModel_Standard_Library) != param;
}

// The position of the selected entry must always be the first parameter.
Expand All @@ -170,8 +155,6 @@ private void SwapPath(int x, int y)
var tempPath = RootLocations[x];
RootLocations[x] = RootLocations[y];
RootLocations[y] = tempPath;

SelectedIndex = y;
}

private void InsertPath()
Expand Down Expand Up @@ -200,7 +183,7 @@ private void UpdatePathAt(int index)
{
var args = new PackagePathEventArgs
{
Path = RootLocations[SelectedIndex]
Path = RootLocations[index]
};

ShowFileDialog(args);
Expand All @@ -214,10 +197,6 @@ private void UpdatePathAt(int index)
private void RemovePathAt(int index)
{
RootLocations.RemoveAt(index);

if (index <= SelectedIndex && SelectedIndex > 0)
SelectedIndex--;

RaiseCanExecuteChanged();
}

Expand All @@ -238,11 +217,6 @@ private void InitializeRootLocations()
if (index != -1)
{
RootLocations[index] = Resources.PackagePathViewModel_Standard_Library;

if (setting is IDisablePackageLoadingPreferences disablePrefs)
{
DisableStandardLibrary = disablePrefs.DisableStandardLibrary;
}
}
}

Expand All @@ -258,5 +232,26 @@ private List<string> CommitRootLocations()

return rootLocations;
}

internal bool IsPathCurrentlyDisabled(string path)
{
if(setting is IDisablePackageLoadingPreferences disablePrefs)
{
//disabled if stdlib disabled and path is stdlib
if ((disablePrefs.DisableStandardLibrary && path == Resources.PackagePathViewModel_Standard_Library)
//or if custompaths disabled and path is custom path
|| (disablePrefs.DisableCustomPackageLocations && setting.CustomPackageFolders.Contains(path))
//or if custompaths disabled and path is known path that is not std.lib - needed because new paths that are not commited
//will not be added to customPackagePaths yet.
|| (disablePrefs.DisableCustomPackageLocations && RootLocations.Contains(path) && path != Resources.PackagePathViewModel_Standard_Library))
{
return true;
}
}

return false;
}


}
}
4 changes: 2 additions & 2 deletions src/DynamoCoreWpf/Views/Core/DynamoView.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1175,8 +1175,8 @@ private void DynamoViewModelRequestPackagePaths(object sender, EventArgs e)
var customNodeManager = dynamoViewModel.Model.CustomNodeManager;
var packageLoader = dynamoViewModel.Model.GetPackageManagerExtension().PackageLoader;
var viewModel = new PackagePathViewModel(packageLoader, loadPackagesParams, customNodeManager);
var view = new PackagePathView(viewModel) { Owner = this };
view.ShowDialog();
//var view = new PackagePathView(viewModel) { Owner = this };
mjkkirschner marked this conversation as resolved.
Show resolved Hide resolved
//view.ShowDialog();
}

private InstalledPackagesView _installedPkgsView;
Expand Down
Loading