Skip to content

Commit

Permalink
Dynamo Default Python engine selection using child MenuItems (#11088)
Browse files Browse the repository at this point in the history
* minimal changes for child menu items

* Code Clean up

* Comments

* Comments
  • Loading branch information
QilongTang authored Sep 2, 2020
1 parent 3cd2591 commit 443e9e5
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 49 deletions.
1 change: 0 additions & 1 deletion src/DynamoCoreWpf/DynamoCoreWpf.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,6 @@
<Compile Include="ViewModels\Core\GalleryViewModel.cs" />
<Compile Include="ViewModels\Core\HomeWorkspaceViewModel.cs" />
<Compile Include="ViewModels\Core\SerializationExtensions.cs" />
<Compile Include="ViewModels\Core\NameValuePairViewModel.cs" />
<Compile Include="ViewModels\PackageManager\IPackageInstaller.cs" />
<Compile Include="ViewModels\PackageManager\PackagePathViewModel.cs" />
<Compile Include="ViewModels\Preview\CompactBubbleViewModel.cs" />
Expand Down
13 changes: 13 additions & 0 deletions src/DynamoCoreWpf/UI/Converters.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1855,6 +1855,19 @@ public object ConvertBack(object value, Type targetType, object parameter, Cultu
}
}

public class CompareToParameterConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
return parameter.ToString() == value.ToString();
}

public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
return parameter as string;
}
}

public class FullyQualifiedNameToDisplayConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
Expand Down
1 change: 1 addition & 0 deletions src/DynamoCoreWpf/UI/Themes/Modern/DynamoConverters.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@
<controls:IsUpdateAvailableToTextConverter x:Key="IsUpdateAvailableToTextConverter"/>
<controls:IsUpdateAvailableBrushConverter x:Key="IsUpdateAvailableBrushConverter"/>
<controls:NumberFormatToBoolConverter x:Key="NumberFormatToBoolConverter"/>
<controls:CompareToParameterConverter x:Key="CompareToParameterConverter"/>
<controls:DoubleDisplay x:Key="DoubleDisplayConverter"/>
<controls:IntegerDisplay x:Key="IntegerDisplayConverter"/>
<controls:SnapRegionMarginConverter x:Key="SnapRegionMarginConverter"/>
Expand Down
11 changes: 0 additions & 11 deletions src/DynamoCoreWpf/ViewModels/Core/DynamoViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,6 @@ public int ScaleFactorLog
private Point transformOrigin;
private bool showStartPage = false;

private ObservableCollection<NameValuePairViewModel<string>> defaultPythonEngineOptions = new ObservableCollection<NameValuePairViewModel<string>>();
public ObservableCollection<NameValuePairViewModel<string>> DefaultPythonEngineOptions
{
get { return defaultPythonEngineOptions; }
}

private ObservableCollection<DefaultWatch3DViewModel> watch3DViewModels = new ObservableCollection<DefaultWatch3DViewModel>();

/// <summary>
Expand Down Expand Up @@ -604,11 +598,6 @@ public struct StartConfiguration

protected DynamoViewModel(StartConfiguration startConfiguration)
{
// These options are currently fixed. Eventually we should make them dynamic I guess.
defaultPythonEngineOptions.Add(new NameValuePairViewModel<string>(string.Empty, WpfResources.DefaultPythonEngineNone));
defaultPythonEngineOptions.Add(new NameValuePairViewModel<string>("IronPython2", "IronPython2"));
defaultPythonEngineOptions.Add(new NameValuePairViewModel<string>("CPython3", "CPython3"));

this.ShowLogin = startConfiguration.ShowLogin;

// initialize core data structures
Expand Down
31 changes: 0 additions & 31 deletions src/DynamoCoreWpf/ViewModels/Core/NameValuePairViewModel.cs

This file was deleted.

20 changes: 14 additions & 6 deletions src/DynamoCoreWpf/Views/Core/DynamoView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -725,12 +725,20 @@
IsChecked="{Binding ShowTabsAndSpacesInScriptEditor, Mode=TwoWay}"
Header="{x:Static p:Resources.DynamoViewSettingsMenuShowTabsAndSpacesInScriptEditor}"/>
<MenuItem Focusable="False"
Header="{x:Static p:Resources.DynamoViewSettingsDefaultPythonEngine}">
<ComboBox ItemsSource="{Binding DefaultPythonEngineOptions}"
SelectedValue="{Binding DefaultPythonEngine, Mode=TwoWay}"
SelectedValuePath="Value"
DisplayMemberPath="Name"
Style="{StaticResource SComboBox}"/>
Header="{x:Static p:Resources.DynamoViewSettingsDefaultPythonEngine}"
Name="PythonEngine">
<MenuItem Focusable="False"
Header="{x:Static p:Resources.DefaultPythonEngineNone}"
IsCheckable="True"
IsChecked="{Binding DefaultPythonEngine,Converter={StaticResource CompareToParameterConverter},ConverterParameter='', Mode=TwoWay}"/>
<MenuItem Focusable="False"
Header="IronPython2"
IsCheckable="True"
IsChecked="{Binding DefaultPythonEngine,Converter={StaticResource CompareToParameterConverter},ConverterParameter='IronPython2', Mode=TwoWay}"/>
<MenuItem Focusable="False"
Header="CPython3"
IsCheckable="True"
IsChecked="{Binding DefaultPythonEngine,Converter={StaticResource CompareToParameterConverter},ConverterParameter='CPython3', Mode=TwoWay}" />
</MenuItem>
<MenuItem Focusable="False"
Header="{x:Static p:Resources.DynamoViewSettingMenuManagePackagePath}"
Expand Down

0 comments on commit 443e9e5

Please sign in to comment.