Skip to content

Commit

Permalink
Show/Hide Workspace References with Checker (#10214)
Browse files Browse the repository at this point in the history
* Show/Hide Workspace References

Add new API on ViewLoadedParams to close tab

* Update Comment
  • Loading branch information
QilongTang authored Dec 13, 2019
1 parent 5b6a40b commit 56e292c
Show file tree
Hide file tree
Showing 7 changed files with 49 additions and 54 deletions.
10 changes: 10 additions & 0 deletions src/DynamoCoreWpf/Extensions/ViewLoadedParams.cs
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,16 @@ public void AddToExtensionsSideBar(IViewExtension viewExtension, ContentControl
}
}

/// <summary>
/// Close the tab for extension UI control element in the extensions side bar.
/// </summary>
/// <param name="viewExtension">Instance of the view extension object that is being added to the extensions side bar.</param>
/// <returns></returns>
public void CloseExtensioninInSideBar(IViewExtension viewExtension)
{
dynamoView.CloseTabItem(viewExtension);
}

public void AddSeparator(MenuBarType type, Separator separatorObj, int index = -1)
{
AddItemToMenu(type, separatorObj, index);
Expand Down
24 changes: 22 additions & 2 deletions src/DynamoCoreWpf/Views/Core/DynamoView.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,17 @@ public DynamoView(DynamoViewModel dynamoViewModel)
FocusableGrid.InputBindings.Clear();
}

/// <summary>
/// This method close a tab item in the right side bar based on passed extension
/// </summary>
/// <param name="viewExtension">Extension to be closed</param>
/// <returns></returns>
internal void CloseTabItem(IViewExtension viewExtension)
{
string tabName = viewExtension.Name;
CloseTab(tabName);
}

// This method adds a tab item to the right side bar and
// sets the extension window as the tab content.
internal TabItem AddTabItem(IViewExtension viewExtension, ContentControl contentControl)
Expand Down Expand Up @@ -242,7 +253,15 @@ internal TabItem AddTabItem(IViewExtension viewExtension, ContentControl content
private void CloseTab(object sender, RoutedEventArgs e)
{
string tabName = (sender as Button).CommandParameter.ToString();

CloseTab(tabName);
}

/// <summary>
/// Close tab by its name
/// </summary>
/// <param name="tabName">tab name</param>
private void CloseTab(string tabName)
{
TabItem tab = tabDynamic.SelectedItem as TabItem;

if (tab != null)
Expand All @@ -259,7 +278,8 @@ private void CloseTab(object sender, RoutedEventArgs e)
// Highlight previously selected tab. if that is removed then Highlight the first tab
if (selectedTab == null || selectedTab.Equals(tab))
{
if (TabItems.Count > 0) {
if (TabItems.Count > 0)
{
selectedTab = TabItems[0];
}
}
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@
<value>Keep Installed Version</value>
</data>
<data name="MenuItemString" xml:space="preserve">
<value>Workspace References</value>
<value>Show Workspace References</value>
</data>
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<data name="NodeLibraryDependency_Loaded" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@
<value>Keep Installed Version</value>
</data>
<data name="MenuItemString" xml:space="preserve">
<value>Workspace References</value>
<value>Show Workspace References</value>
</data>
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<data name="NodeLibraryDependency_Loaded" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@
<StatusBar
Name="RestartBanner"
Background="LightCoral"
DockPanel.Dock="Top"
DockPanel.Dock="Bottom"
Height="55"
Margin="1"
Visibility="Hidden">
Expand All @@ -225,49 +225,6 @@
</Border>
</StatusBarItem>
</StatusBar>
<!-- Feedback Banner -->
<StatusBar Background="{StaticResource FeedbackSectionBackground}" DockPanel.Dock="Bottom" Height="55" Margin="1">
<!-- Preview text -->
<StatusBarItem>
<Border Height="50">
<TextBlock TextWrapping="Wrap" Padding="10,0,10,0" FontSize="15" Foreground="White" Text="{x:Static p:Resources.PreviewText}" VerticalAlignment="Center"/>
</Border>
</StatusBarItem>
<StatusBarItem Width="153" Margin="10,0,0,0" Height="40">
<Border Name="FeedbackBorder" BorderThickness="1">
<Border.Style>
<Style>
<Style.Triggers>
<Trigger Property="Border.IsMouseOver" Value="True">
<Setter Property="Border.BorderBrush" Value="White" />
</Trigger>
<Trigger Property="Border.IsMouseOver" Value="False">
<Setter Property="Border.BorderBrush" Value="#373737" />
</Trigger>
</Style.Triggers>
</Style>
</Border.Style>
<!-- Feedback button -->
<Button HorizontalAlignment="Right"
Width="150" Click="ProvideFeedback" Background="#373737" Height="30">
<TextBlock TextWrapping="Wrap" FontSize="15" Foreground="White" Height="20" Text="{x:Static w:Resources.ProvideFeedbackButton}" VerticalAlignment="Center"/>
<Button.Style>
<Style TargetType="{x:Type Button}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Button}">
<Border Background="{TemplateBinding Background}">
<ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</Button.Style>
</Button>
</Border>
</StatusBarItem>
</StatusBar>
</DockPanel>
</Grid>
</UserControl>
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,20 @@ public void Loaded(ViewLoadedParams viewLoadedParams)
};

// Adding a button in view menu to refresh and show manually
packageDependencyMenuItem = new MenuItem { Header = Resources.MenuItemString };
packageDependencyMenuItem = new MenuItem { Header = Resources.MenuItemString, IsCheckable = true, IsChecked = false };
packageDependencyMenuItem.Click += (sender, args) =>
{
// Refresh dependency data
DependencyView.DependencyRegen(viewLoadedParams.CurrentWorkspaceModel as WorkspaceModel);
viewLoadedParams.AddToExtensionsSideBar(this, DependencyView);
if (packageDependencyMenuItem.IsChecked)
{
// Refresh dependency data
DependencyView.DependencyRegen(viewLoadedParams.CurrentWorkspaceModel as WorkspaceModel);
viewLoadedParams.AddToExtensionsSideBar(this, DependencyView);
}
else
{
viewLoadedParams.CloseExtensioninInSideBar(this);
}
};
viewLoadedParams.AddMenuItem(MenuBarType.View, packageDependencyMenuItem);
}
Expand Down

0 comments on commit 56e292c

Please sign in to comment.