-
Notifications
You must be signed in to change notification settings - Fork 636
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Graph properties view extension (#11675)
* initial commit * TestCommit * Basic adding/editing of custom properties implemented. Removing custom properties not implemented yet. * CustomPropertyControl element removal implemented. * Revert "TestCommit" * Various style (xaml) fixes. * PR comments SHK picked up largely. * Additional cleanup. * Corrected changes from latest PR. * Added validation logic to Uri textbox. -Validation Rule -ValidationErrorTemplate -Fixed empty textbox error. * Commented code cleanup. * Dispose methods added to ViewModel and to Extension. * Quick correction to override Loaded method. * Removed redundant interface. * Update .gitignore * Various edits around handling Custom Property behaviour correctly. * Update .gitignore * Styling updates * Update GraphMetadataView.xaml * add extension tests * Clean up * Update PackageManagerExtensionLoadingTests.cs * comment updates * fix margin and add new icons * add summaries * Dont show extension in CustomNode ws + add CustomProp name textbox highlight * Mark graph dirty on props changed * use absolute URI Co-authored-by: Marco Juliani <[email protected]> Co-authored-by: Craig Long <[email protected]>
- Loading branch information
1 parent
8aff378
commit 3c861d2
Showing
27 changed files
with
2,001 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
78 changes: 78 additions & 0 deletions
78
src/GraphMetadataViewExtension/Controls/CustomPropertyControl.xaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
<UserControl x:Class="Dynamo.GraphMetadata.Controls.CustomPropertyControl" | ||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | ||
xmlns:local="clr-namespace:Dynamo.GraphMetadata.Controls" | ||
xmlns:fa="http://schemas.fontawesome.io/icons/" | ||
xmlns:ui="clr-namespace:Dynamo.UI;assembly=DynamoCoreWpf" | ||
mc:Ignorable="d" | ||
d:DesignHeight="450" d:DesignWidth="200"> | ||
|
||
<UserControl.Resources> | ||
<ResourceDictionary> | ||
<ResourceDictionary.MergedDictionaries> | ||
<ui:SharedResourceDictionary Source="{x:Static ui:SharedDictionaryManager.DynamoModernDictionaryUri}" /> | ||
<ui:SharedResourceDictionary Source="{x:Static ui:SharedDictionaryManager.DynamoConvertersDictionaryUri}" /> | ||
<ui:SharedResourceDictionary Source="{x:Static ui:SharedDictionaryManager.DynamoColorsAndBrushesDictionaryUri}" /> | ||
</ResourceDictionary.MergedDictionaries> | ||
</ResourceDictionary> | ||
</UserControl.Resources> | ||
<Grid DataContext="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type local:CustomPropertyControl}}}" | ||
HorizontalAlignment="Stretch"> | ||
<Grid.RowDefinitions> | ||
<RowDefinition Height="Auto" /> | ||
<RowDefinition Height="Auto" /> | ||
</Grid.RowDefinitions> | ||
<Grid Grid.Row="0"> | ||
<Grid.ColumnDefinitions> | ||
<ColumnDefinition Width="*" /> | ||
<ColumnDefinition Width="20" /> | ||
<ColumnDefinition Width="20" /> | ||
</Grid.ColumnDefinitions> | ||
<TextBox x:Name="propertyNameText" | ||
Grid.Column="0" | ||
Background="Transparent" | ||
BorderBrush="Transparent" | ||
Foreground="{StaticResource NodeNameForeground}" | ||
Text="{Binding PropertyName, Mode=TwoWay, UpdateSourceTrigger=LostFocus}" | ||
IsEnabled="False" | ||
BorderThickness="1" | ||
Padding="-3,0" | ||
Margin="0" | ||
CaretBrush="White"> | ||
</TextBox> | ||
<Button Grid.Column="1" | ||
Background="Transparent" | ||
BorderThickness="0" | ||
Command="{Binding EditPropertyNameCmd}"> | ||
<Button.Template> | ||
<ControlTemplate> | ||
<fa:ImageAwesome Icon="Pencil" | ||
Height="16px" | ||
Grid.Column="1" | ||
Foreground="{StaticResource FilterIconColor}" /> | ||
</ControlTemplate> | ||
</Button.Template> | ||
</Button> | ||
|
||
<Button Grid.Column="2" | ||
Background="Transparent" | ||
BorderThickness="0" | ||
Command="{Binding DeletePropertyNameCmd}"> | ||
<Button.Template> | ||
<ControlTemplate> | ||
<Image Width="16px" | ||
Source="/GraphMetadataViewExtension;component/Resources/close-thick-grey-16px.png" /> | ||
</ControlTemplate> | ||
</Button.Template> | ||
</Button> | ||
</Grid> | ||
<TextBox Grid.Row="1" BorderBrush="{StaticResource BorderBrushWhite}" | ||
Background="{StaticResource SearchBoxBackgroundColor}" | ||
Foreground="{StaticResource NestedMemberTextColor}" | ||
Margin="0,5" | ||
Padding="0,5" | ||
Text="{Binding PropertyValue, Mode=TwoWay, UpdateSourceTrigger=LostFocus}" /> | ||
</Grid> | ||
</UserControl> |
97 changes: 97 additions & 0 deletions
97
src/GraphMetadataViewExtension/Controls/CustomPropertyControl.xaml.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
using System; | ||
using System.Windows; | ||
using System.Windows.Controls; | ||
using Dynamo.UI.Commands; | ||
|
||
namespace Dynamo.GraphMetadata.Controls | ||
{ | ||
/// <summary> | ||
/// Interaction logic for CustomPropertyControl.xaml | ||
/// </summary> | ||
public partial class CustomPropertyControl : UserControl | ||
{ | ||
/// <summary> | ||
/// This command corresponds to an edit of a CustomProperty name. | ||
/// </summary> | ||
public DelegateCommand EditPropertyNameCmd { get; set; } | ||
/// <summary> | ||
/// This command corresponds to a deletion of a CustomProperty from a collection of CustomProperties in the ViewModel. | ||
/// </summary> | ||
public DelegateCommand DeletePropertyNameCmd { get; set; } | ||
public bool PropertyNameEnabled { get; set; } | ||
|
||
/// <summary> | ||
/// This event fires when the 'Delete' command is triggered. It signals to the ViewModel that the corresponding CustomProperty ought to be removed. | ||
/// </summary> | ||
public event EventHandler RequestDelete; | ||
|
||
private void OnRequestDelete(EventArgs e) | ||
{ | ||
RequestDelete?.Invoke(this, e); | ||
} | ||
|
||
public CustomPropertyControl() | ||
{ | ||
InitializeComponent(); | ||
InitializeCommands(); | ||
PropertyNameEnabled = false; | ||
} | ||
|
||
private void InitializeCommands() | ||
{ | ||
this.EditPropertyNameCmd = new DelegateCommand(EditPropertyNameCmdExecute); | ||
this.DeletePropertyNameCmd = new DelegateCommand(DeletePropertyNameCmdExecute); | ||
} | ||
|
||
private void EditPropertyNameCmdExecute(object obj) | ||
{ | ||
PropertyNameEnabled = !PropertyNameEnabled; | ||
propertyNameText.IsEnabled = PropertyNameEnabled; | ||
propertyNameText.Focus(); | ||
propertyNameText.CaretIndex = PropertyName.Length; | ||
|
||
propertyNameText.LostFocus += DisableEditable; | ||
} | ||
|
||
private void DisableEditable(object sender, RoutedEventArgs e) | ||
{ | ||
propertyNameText.IsEnabled = false; | ||
propertyNameText.LostFocus -= DisableEditable; | ||
} | ||
|
||
private void DeletePropertyNameCmdExecute(object obj) | ||
{ | ||
if (string.IsNullOrEmpty(this.PropertyName)) return; | ||
|
||
OnRequestDelete(EventArgs.Empty); | ||
} | ||
|
||
#region DependencyProperties | ||
|
||
public string PropertyName | ||
{ | ||
get { return (string)GetValue(PropertyNameProperty); } | ||
set { SetValue(PropertyNameProperty, value); } | ||
} | ||
|
||
public static readonly DependencyProperty PropertyNameProperty = DependencyProperty.Register( | ||
nameof(PropertyName), | ||
typeof(string), | ||
typeof(CustomPropertyControl) | ||
); | ||
|
||
public string PropertyValue | ||
{ | ||
get { return (string)GetValue(PropertyValueProperty); } | ||
set { SetValue(PropertyValueProperty, value); } | ||
} | ||
|
||
public static readonly DependencyProperty PropertyValueProperty = DependencyProperty.Register( | ||
nameof(PropertyValue), | ||
typeof(string), | ||
typeof(CustomPropertyControl) | ||
); | ||
|
||
#endregion | ||
} | ||
} |
81 changes: 81 additions & 0 deletions
81
src/GraphMetadataViewExtension/Controls/ImageSelector.xaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
<UserControl x:Class="Dynamo.GraphMetadata.Controls.ImageSelector" | ||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | ||
xmlns:local="clr-namespace:Dynamo.GraphMetadata.Controls" | ||
xmlns:properties="clr-namespace:Dynamo.GraphMetadata.Properties" | ||
xmlns:convertes="clr-namespace:Dynamo.GraphMetadata.Converters" | ||
xmlns:ui="clr-namespace:Dynamo.UI;assembly=DynamoCoreWpf" | ||
mc:Ignorable="d" | ||
d:DesignHeight="198" d:DesignWidth="314"> | ||
<UserControl.Resources> | ||
<ResourceDictionary> | ||
<ResourceDictionary.MergedDictionaries> | ||
<ui:SharedResourceDictionary Source="{x:Static ui:SharedDictionaryManager.DynamoModernDictionaryUri}" /> | ||
<ui:SharedResourceDictionary Source="{x:Static ui:SharedDictionaryManager.DynamoConvertersDictionaryUri}" /> | ||
<ui:SharedResourceDictionary Source="{x:Static ui:SharedDictionaryManager.DynamoColorsAndBrushesDictionaryUri}" /> | ||
</ResourceDictionary.MergedDictionaries> | ||
<convertes:BooleanInverseConverter x:Key="BooleanInverseConverter" /> | ||
<convertes:BooleansToVisibilityConverter x:Key="BooleansToVisibilityConverter" /> | ||
|
||
<SolidColorBrush x:Key="ButtonOverlayBrush" Color="Black" Opacity="0.5" /> | ||
<SolidColorBrush x:Key="ButtonOverlayPressedBrush" Color="Black" Opacity="0.3" /> | ||
|
||
<Style x:Key="OverlayButton" TargetType="Button"> | ||
<Setter Property="Background" Value="{StaticResource ButtonOverlayBrush}" /> | ||
<Setter Property="Template"> | ||
<Setter.Value> | ||
<ControlTemplate TargetType="{x:Type Button}"> | ||
<Border Background="{TemplateBinding Background}" BorderBrush="Black" BorderThickness="1"> | ||
<ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center" /> | ||
</Border> | ||
</ControlTemplate> | ||
</Setter.Value> | ||
</Setter> | ||
<Style.Triggers> | ||
<DataTrigger | ||
Binding="{Binding Path=IsMouseOver, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type local:ImageSelector}}}" | ||
Value="False"> | ||
<Setter Property="Visibility" Value="Collapsed" /> | ||
</DataTrigger> | ||
<Trigger Property="IsMouseOver" Value="True"> | ||
<Setter Property="Background" Value="{StaticResource ButtonOverlayBrush}" /> | ||
</Trigger> | ||
<Trigger Property="IsPressed" Value="True"> | ||
<Setter Property="Background" Value="{StaticResource ButtonOverlayPressedBrush}" /> | ||
</Trigger> | ||
</Style.Triggers> | ||
</Style> | ||
</ResourceDictionary> | ||
</UserControl.Resources> | ||
|
||
<Border | ||
DataContext="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type local:ImageSelector}}}" | ||
BorderThickness="1" | ||
BorderBrush="#FF3F4040"> | ||
<Grid | ||
Background="{StaticResource SearchBoxBackgroundColor}"> | ||
<Image | ||
Source="{Binding Image}" | ||
Stretch="Uniform" /> | ||
<TextBlock | ||
Text="{x:Static properties:Resources.ImageSelector_Message_NoImageSelected}" | ||
VerticalAlignment="Center" | ||
HorizontalAlignment="Center"> | ||
<TextBlock.Visibility> | ||
<MultiBinding Converter="{StaticResource BooleansToVisibilityConverter}"> | ||
<Binding Path="IsMouseOver" Converter="{StaticResource BooleanInverseConverter}" /> | ||
<Binding Path="HasImage" Converter="{StaticResource BooleanInverseConverter}" /> | ||
</MultiBinding> | ||
</TextBlock.Visibility> | ||
</TextBlock> | ||
|
||
<Button | ||
x:Name="btn_ImageSelection" | ||
Style="{StaticResource OverlayButton}" | ||
Content="{Binding UserFeedback}"> | ||
</Button> | ||
</Grid> | ||
</Border> | ||
</UserControl> |
Oops, something went wrong.