Skip to content

Commit 638ebdb

Browse files
committed
Bind DeployProfile dialog to network item data.
1 parent 3250dd3 commit 638ebdb

10 files changed

+237
-3
lines changed

tests/Stratis.DevEx.Wpf.Test/BlockchainExplorer/BlockchainExplorerToolWindowControl.xaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
<CommandBinding Command="{x:Static stratisui:BlockchainExplorerTree.NewEndpointCmd}" Executed="NewEndpointCmd_Executed" />
5151
<CommandBinding Command="{x:Static stratisui:BlockchainExplorerTree.DeleteEndpointCmd}" Executed="DeleteEndpointCmd_Executed" CanExecute="DeleteEndpointCmd_CanExecute" />
5252
<CommandBinding Command="{x:Static stratisui:BlockchainExplorerTree.EditAccountCmd}" Executed="EditAccountCmd_Executed" />
53+
<CommandBinding Command="{x:Static stratisui:BlockchainExplorerTree.NewDeployProfileCmd}" Executed="NewDeployProfileCmd_Executed" />
5354
</UserControl.CommandBindings>
5455

5556
</UserControl>

tests/Stratis.DevEx.Wpf.Test/BlockchainExplorer/BlockchainExplorerToolWindowControl.xaml.cs

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,7 @@ private async void NewNetworkCmd_Executed(object sender, ExecutedRoutedEventArgs
171171
{
172172
accounts.AddAccount(acct);
173173
}
174+
t.AddChild(BlockchainInfoKind.Folder, "Deploy Profiles");
174175
if (!tree.RootItem.Save("BlockchainExplorerTree", out var ex))
175176
{
176177
#if IS_VSIX
@@ -277,7 +278,7 @@ private void DeleteEndpointCmd_Executed(object sender, ExecutedRoutedEventArgs e
277278
private void DeleteEndpointCmd_CanExecute(object sender, CanExecuteRoutedEventArgs e)
278279
{
279280
var item = GetSelectedItem(sender);
280-
var endpoints = item.GetEndPoints();
281+
var endpoints = item.GetNetworkEndPoints();
281282
if (endpoints.Count() == 1)
282283
{
283284
e.CanExecute = false;
@@ -510,5 +511,38 @@ private async void EditAccountCmd_Executed(object sender, ExecutedRoutedEventArg
510511
#endif
511512
}
512513
}
514+
515+
private async void NewDeployProfileCmd_Executed(object sender, ExecutedRoutedEventArgs e)
516+
{
517+
var window = (BlockchainExplorerToolWindowControl)sender;
518+
var tree = window.BlockchainExplorerTree;
519+
var item = GetSelectedItem(sender);
520+
var dw = new BlockchainExplorerDialog(RootContentDialog)
521+
{
522+
Title = "Add Deploy Profile",
523+
PrimaryButtonIcon = new SymbolIcon(SymbolRegular.Save20),
524+
Content = (StackPanel)TryFindResource("AddDeployProfileDialog"),
525+
PrimaryButtonText = "Save",
526+
CloseButtonText = "Cancel",
527+
};
528+
var sp = (StackPanel)dw.Content;
529+
var name = (Wpc.TextBox)((StackPanel)sp.Children[0]).Children[1];
530+
var endpoint = (ComboBox)((StackPanel)sp.Children[1]).Children[1];
531+
var accounts = (ComboBox)((StackPanel)sp.Children[2]).Children[1];
532+
endpoint.ItemsSource = item.GetNetworkEndPoints();
533+
endpoint.SelectedIndex = 0;
534+
accounts.ItemsSource = item.GetNetworkAccounts();
535+
var validForClose = false;
536+
537+
dw.ButtonClicked += (cd, args) =>
538+
{
539+
validForClose = true;
540+
};
541+
dw.Closing += (d, args) =>
542+
{
543+
args.Cancel = !validForClose;
544+
};
545+
var r = await dw.ShowAsync();
546+
}
513547
}
514548
}

tests/Stratis.DevEx.Wpf.Test/BlockchainExplorer/BlockchainExplorerTree.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ public class BlockchainExplorerTree : TreeViewBase<BlockchainInfo>
3131

3232
public static RoutedCommand EditAccountCmd { get; } = new RoutedCommand();
3333

34+
public static RoutedCommand NewDeployProfileCmd { get; } = new RoutedCommand();
35+
3436
public BlockchainInfo RootItem => Items?.First();
3537
#endregion
3638

tests/Stratis.DevEx.Wpf.Test/BlockchainExplorer/BlockchainExplorerTreeResources.xaml

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,41 @@
214214
</DrawingImage.Drawing>
215215
</DrawingImage>
216216

217+
<DrawingImage x:Key="DeployDrawingImage">
218+
<DrawingImage.Drawing>
219+
<DrawingGroup ClipGeometry="M0,0 V36 H36 V0 H0 Z">
220+
<GeometryDrawing Brush="{DynamicResource {x:Static stratisui:VSTheme.ToolWindowTextKey}}" Geometry="F1 M36,36z M0,0z M33,2L22.1,2A1,1,0,0,0,22.1,4L30.63,4 21.81,13A1,1,0,1,0,23.24,14.4L32,5.46 32,13.9A1,1,0,0,0,34,13.9L34,3A1,1,0,0,0,33,2z" />
221+
<GeometryDrawing Brush="{DynamicResource {x:Static stratisui:VSTheme.ToolWindowTextKey}}" Geometry="F1 M36,36z M0,0z M12.46,10.73A1,1,0,0,0,11.46,10.73L2.78,15.73 12,21 21.19,15.74z" />
222+
<GeometryDrawing Brush="{DynamicResource {x:Static stratisui:VSTheme.ToolWindowTextKey}}" Geometry="F1 M36,36z M0,0z M2,27.73A1,1,0,0,0,2.5,28.6L11,33.46 11,22.46 2,17.28z" />
223+
<GeometryDrawing Brush="{DynamicResource {x:Static stratisui:VSTheme.ToolWindowTextKey}}" Geometry="F1 M36,36z M0,0z M13,33.46L21.5,28.6A1,1,0,0,0,22,27.73L22,17.29 13,22.44z" />
224+
<GeometryDrawing>
225+
<GeometryDrawing.Brush>
226+
<SolidColorBrush Color="{DynamicResource {x:Static stratisui:VSTheme.ToolWindowTextKey}}" Opacity="0" />
227+
</GeometryDrawing.Brush>
228+
<GeometryDrawing.Geometry>
229+
<RectangleGeometry RadiusX="0" RadiusY="0" Rect="0,0,36,36" />
230+
</GeometryDrawing.Geometry>
231+
</GeometryDrawing>
232+
</DrawingGroup>
233+
</DrawingImage.Drawing>
234+
</DrawingImage>
235+
236+
<DrawingImage x:Key="DeployProfileDrawingImage">
237+
<DrawingImage.Drawing>
238+
<DrawingGroup ClipGeometry="M0,0 V24 H24 V0 H0 Z">
239+
<GeometryDrawing Brush="{DynamicResource {x:Static stratisui:VSTheme.ToolWindowTextKey}}" Geometry="F1 M24,24z M0,0z M8.95305171,17.9846747C8.72737466,19.1334216,7.71488744,20,6.5,20L4.5,20C4.22385763,20,4,19.7761424,4,19.5L4,17.5C4,16.2851126,4.86657841,15.2726253,6.0153253,15.0469483L6.02714614,14.7041437C6.04713299,14.1245251,6.10682628,13.555636,6.20352226,13L2.5,13C2.1462677,13,1.90438878,12.6427369,2.03576165,12.3143047L4.03576165,7.31430466C4.11169333,7.12447547,4.29554771,7,4.5,7L9,7C9.02538451,7 9.05032719,7.00189166 9.07469478,7.0055417 11.4290981,4.32146349 14.9247139,2.67696313 18.771296,2.80960389 19.3819666,2.8306615 19.9902263,2.89709634 20.5910446,3.008359 20.7946429,3.04606238 20.9539376,3.20535713 20.991641,3.40895537 21.812186,7.83989855 20.1522623,12.1558183 16.9947249,14.9271075 16.9982004,14.9509022 17,14.9752409 17,15L17,19.5C17,19.7044523,16.8755245,19.8883067,16.6856953,19.9642383L11.6856953,21.9642383C11.3572631,22.0956112,11,21.8537323,11,21.5L11,17.7949378C10.4368132,17.8936903,9.86739064,17.9531458,9.29585627,17.9728539L8.95305171,17.9846747z M7.98749247,17.6945992L6.30540075,16.0125075C5.56890748,16.1079151,5,16.7375198,5,17.5L5,19 6.5,19C7.26248018,19,7.8920849,18.4310925,7.98749247,17.6945992L7.98749247,17.6945992z M12,17.5770127L12,20.7614835 16,19.1614835 16,15.7132231C14.8178863,16.5520811,13.4713529,17.1925443,12,17.5770127L12,17.5770127z M6.42079004,12C6.80202391,10.5414825,7.44257093,9.19144113,8.28872675,8L4.83851648,8 3.23851648,12 6.42079004,12 6.42079004,12z M8.69991595,16.9928092L9.26139399,16.9734479C9.82252402,16.9540985 10.3814387,16.8930532 10.9335157,16.7908167 16.9701904,15.672914 20.9957193,9.95997934 20.0664857,3.93363717 19.626205,3.86599452 19.1822172,3.82436794 18.7368337,3.80900989 12.4850041,3.59342956 7.24213247,8.48677642 7.02655214,14.738606L7.00719083,15.300084 8.69991595,16.9928092z M14,13C12.3431458,13 11,11.6568542 11,10 11,8.34314575 12.3431458,7 14,7 15.6568542,7 17,8.34314575 17,10 17,11.6568542 15.6568542,13 14,13z M14,12C15.1045695,12 16,11.1045695 16,10 16,8.8954305 15.1045695,8 14,8 12.8954305,8 12,8.8954305 12,10 12,11.1045695 12.8954305,12 14,12z" />
240+
</DrawingGroup>
241+
</DrawingImage.Drawing>
242+
</DrawingImage>
243+
244+
<DrawingImage x:Key="AddDeployProfileDrawingImage">
245+
<DrawingImage.Drawing>
246+
<DrawingGroup ClipGeometry="M0,0 V24 H24 V0 H0 Z">
247+
<GeometryDrawing Brush="{DynamicResource {x:Static stratisui:VSTheme.ToolWindowTextKey}}" Geometry="F1 M24,24z M0,0z M19,5L23,5 23,6 19,6 19,10 18,10 18,6 14,6 14,5 18,5 18,1 19,1z M20,12L21,12 21,22 2,22 2,3 12,3 12,12z M11,13L3,13 3,21 11,21z M11,4L3,4 3,12 11,12z M20,13L12,13 12,21 20,21z" />
248+
</DrawingGroup>
249+
</DrawingImage.Drawing>
250+
</DrawingImage>
251+
217252
<!-- TreeView items data template-->
218253
<DataTemplate x:Key="BlockchainInfoTemplate" DataType="{x:Type vm:BlockchainInfo}">
219254
<StackPanel x:Name="GroupPanel" Orientation="Horizontal" Margin="0,2,0,2">
@@ -242,6 +277,13 @@
242277
</MultiDataTrigger.Conditions>
243278
<Setter TargetName="NodeImage" Property="Source" Value="{StaticResource AccountsDrawingImage}" />
244279
</MultiDataTrigger>
280+
<MultiDataTrigger>
281+
<MultiDataTrigger.Conditions>
282+
<Condition Binding="{Binding Path=Kind}" Value="Folder" />
283+
<Condition Binding="{Binding Path=Name}" Value="Deploy Profiles" />
284+
</MultiDataTrigger.Conditions>
285+
<Setter TargetName="NodeImage" Property="Source" Value="{StaticResource DeployProfileDrawingImage}" />
286+
</MultiDataTrigger>
245287
<DataTrigger Binding="{Binding Path=Kind}" Value="Network">
246288
<Setter TargetName="NodeText" Property="ToolTipService.InitialShowDelay" Value="100" />
247289
<Setter TargetName="NodeText" Property="ToolTipService.Placement" Value="MousePoint" />
@@ -327,6 +369,11 @@
327369
<Image Source="{StaticResource GlobeDrawingImage}" />
328370
</MenuItem.Icon>
329371
</MenuItem>
372+
<MenuItem Header="Add Deploy Profile..." Command="{x:Static stratisui:BlockchainExplorerTree.NewDeployProfileCmd}">
373+
<MenuItem.Icon>
374+
<Image Source="{StaticResource AddDeployProfileDrawingImage}" />
375+
</MenuItem.Icon>
376+
</MenuItem>
330377
<MenuItem Header="Delete" Command="{x:Static stratisui:BlockchainExplorerTree.DeleteNetworkCmd}">
331378
<MenuItem.Icon>
332379
<Image Source="{StaticResource DeleteNetworkDrawingImage}" />
@@ -467,4 +514,29 @@
467514
<ui:TextBox x:Name="AccountLabelTextBox" Width="150" Margin="0,2,10,4" VerticalAlignment="Center" />
468515
</StackPanel>
469516
</StackPanel>
517+
518+
<StackPanel x:Key="AddDeployProfileDialog" Orientation="Vertical" VerticalAlignment="Top" Style="{DynamicResource DialogStyle}">
519+
<StackPanel Orientation="Vertical" >
520+
<ui:TextBlock Text="Deploy Profile Name:" VerticalAlignment="Center" Margin="1,0,0,2" />
521+
<ui:TextBox x:Name="DeployProfileNameTextBox" Width="150" Margin="0,2,10,4" VerticalAlignment="Center" />
522+
</StackPanel>
523+
<StackPanel Orientation="Vertical">
524+
<ui:TextBlock Text="Select the deployment endpoint:" VerticalAlignment="Center" Margin="1,0,0,2" />
525+
<ComboBox x:Name="DeployProfileEndpointListView" Width="150" Margin="0,2,10,4" VerticalAlignment="Center"/>
526+
</StackPanel>
527+
<StackPanel Orientation="Vertical">
528+
<ui:TextBlock Text="Select the account to use:" VerticalAlignment="Center" Margin="1,0,0,2" />
529+
<ComboBox x:Name="DeployProfileAccountListView" Width="150" Margin="0,2,10,4" VerticalAlignment="Center"/>
530+
</StackPanel>
531+
<StackPanel Orientation="Vertical">
532+
<ui:TextBlock Text="Account private key (optional):" VerticalAlignment="Center" Margin="1,0,0,2" />
533+
<ui:PasswordBox Name="DeployProfileAccountPrivateKeyPasswordBox" Width="150" Margin="0,2,10,4" VerticalAlignment="Center"/>
534+
</StackPanel>
535+
<StackPanel Orientation="Vertical">
536+
<Grid>
537+
<ui:TextBlock Name = "AddDeployProfileDialogValidationErrors" Grid.Row="0" Foreground="Red" Visibility="Hidden" VerticalAlignment="Center" TextWrapping="WrapWithOverflow"
538+
ScrollViewer.VerticalScrollBarVisibility="Auto" ScrollViewer.CanContentScroll="True"/>
539+
</Grid>
540+
</StackPanel>
541+
</StackPanel>
470542
</ResourceDictionary>

tests/Stratis.DevEx.Wpf.Test/BlockchainExplorer/BlockchainViewModel.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ public enum BlockchainInfoKind
2323
Network,
2424
Endpoint,
2525
Account,
26-
Contract
26+
Contract,
27+
DeployProfile
2728
}
2829

2930
public class BlockchainInfo
@@ -128,7 +129,9 @@ public BlockchainInfo AddAccount(string pubkey, string label = null)
128129

129130
public IEnumerable<BlockchainInfo> GetChildren(BlockchainInfoKind kind) => Children.Where(c => c.Kind == kind);
130131

131-
public IEnumerable<BlockchainInfo> GetEndPoints() => GetChildren(BlockchainInfoKind.Endpoint);
132+
public IEnumerable<string> GetNetworkEndPoints() => GetChild("Endpoints", BlockchainInfoKind.Folder).GetChildren(BlockchainInfoKind.Endpoint).Select(bi => bi.Name);
133+
134+
public IEnumerable<string> GetNetworkAccounts() => GetChild("Accounts", BlockchainInfoKind.Folder).GetChildren(BlockchainInfoKind.Account).Select(bi => bi.Name);
132135

133136
public bool Save(string path, out Exception e)
134137
{
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<Window x:Class="Stratis.VS.StratisEVM.UI.DeploySolidityProjectToolWindow"
2+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4+
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
5+
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
6+
xmlns:wpftv="clr-namespace:Hardcodet.Wpf.GenericTreeView;assembly=Hardcodet.Wpf.GenericTreeView"
7+
xmlns:stratisui="clr-namespace:Stratis.VS.StratisEVM.UI"
8+
xmlns:vm="clr-namespace:Stratis.VS.StratisEVM.UI.ViewModel"
9+
mc:Ignorable="d"
10+
Title="MainWindow" Height="450" Width="800">
11+
<stratisui:DeploySolidityProjectToolWindowControl />
12+
</Window>
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
using System.Windows;
7+
using System.Windows.Controls;
8+
using System.Windows.Data;
9+
using System.Windows.Documents;
10+
using System.Windows.Input;
11+
using System.Windows.Media;
12+
using System.Windows.Media.Imaging;
13+
using System.Windows.Navigation;
14+
using System.Windows.Shapes;
15+
16+
namespace Stratis.VS.StratisEVM.UI
17+
{
18+
/// <summary>
19+
/// Interaction logic for MainWindow.xaml
20+
/// </summary>
21+
public partial class DeploySolidityProjectToolWindow : Window
22+
{
23+
public DeploySolidityProjectToolWindow()
24+
{
25+
InitializeComponent();
26+
}
27+
28+
29+
}
30+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<UserControl x:Class="Stratis.VS.StratisEVM.UI.DeploySolidityProjectToolWindowControl"
2+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4+
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
5+
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
6+
xmlns:ui="http://schemas.lepo.co/wpfui/2022/xaml"
7+
mc:Ignorable="d"
8+
d:DesignHeight="300" d:DesignWidth="300"
9+
xmlns:stratisui="clr-namespace:Stratis.VS.StratisEVM.UI;assembly="
10+
Foreground="{DynamicResource {x:Static stratisui:VSTheme.ToolWindowTextKey}}"
11+
Background="{DynamicResource {x:Static stratisui:VSTheme.ToolWindowBackgroundKey}}">
12+
13+
<UserControl.Resources>
14+
<ResourceDictionary>
15+
<ResourceDictionary.MergedDictionaries>
16+
<ui:ThemesDictionary Theme="Light" />
17+
<ui:ControlsDictionary />
18+
</ResourceDictionary.MergedDictionaries>
19+
</ResourceDictionary>
20+
</UserControl.Resources>
21+
22+
<Grid>
23+
<Grid.RowDefinitions>
24+
<RowDefinition />
25+
</Grid.RowDefinitions>
26+
<StackPanel Orientation="Vertical" Grid.Row="0">
27+
28+
</StackPanel>
29+
<ContentPresenter x:Name="RootContentDialog" Grid.Row="0"/>
30+
</Grid>
31+
</UserControl>
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
using System.Diagnostics.CodeAnalysis;
2+
using System.Windows;
3+
using System.Windows.Controls;
4+
5+
namespace Stratis.VS.StratisEVM.UI
6+
{
7+
/// <summary>
8+
/// Interaction logic for DeploySolidityProjectToolWindowControl.
9+
/// </summary>
10+
public partial class DeploySolidityProjectToolWindowControl : UserControl
11+
{
12+
/// <summary>
13+
/// Initializes a new instance of the <see cref="DeploySolidityProjectToolWindowControl"/> class.
14+
/// </summary>
15+
public DeploySolidityProjectToolWindowControl()
16+
{
17+
this.InitializeComponent();
18+
VSTheme.WatchThemeChanges();
19+
}
20+
21+
/// <summary>
22+
/// Handles click on the button by displaying a message box.
23+
/// </summary>
24+
/// <param name="sender">The event sender.</param>
25+
/// <param name="e">The event args.</param>
26+
[SuppressMessage("Microsoft.Globalization", "CA1300:SpecifyMessageBoxOptions", Justification = "Sample code")]
27+
[SuppressMessage("StyleCop.CSharp.NamingRules", "SA1300:ElementMustBeginWithUpperCaseLetter", Justification = "Default event handler naming pattern")]
28+
private void button1_Click(object sender, RoutedEventArgs e)
29+
{
30+
MessageBox.Show(
31+
string.Format(System.Globalization.CultureInfo.CurrentUICulture, "Invoked '{0}'", this.ToString()),
32+
"DeploySolidityProjectToolWindow");
33+
}
34+
}
35+
}

tests/Stratis.DevEx.Wpf.Test/Stratis.DevEx.Wpf.Test.csproj

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,12 @@
7171
<Compile Include="BlockchainExplorer\BlockchainExplorerDialog.xaml.cs">
7272
<DependentUpon>BlockchainExplorerDialog.xaml</DependentUpon>
7373
</Compile>
74+
<Compile Include="DeploySolidityProject\DeploySolidityProjectToolWindow.xaml.cs">
75+
<DependentUpon>DeploySolidityProjectToolWindow.xaml</DependentUpon>
76+
</Compile>
77+
<Compile Include="DeploySolidityProject\DeploySolidityProjectToolWindowControl.xaml.cs">
78+
<DependentUpon>DeploySolidityProjectToolWindowControl.xaml</DependentUpon>
79+
</Compile>
7480
<Compile Include="StratisEVMBlockchainDashboard\StratisEVMBlockchainDashboardToolWindowControl.xaml.cs">
7581
<DependentUpon>StratisEVMBlockchainDashboardToolWindowControl.xaml</DependentUpon>
7682
</Compile>
@@ -93,6 +99,14 @@
9399
<Generator>MSBuild:Compile</Generator>
94100
<SubType>Designer</SubType>
95101
</Page>
102+
<Page Include="DeploySolidityProject\DeploySolidityProjectToolWindow.xaml">
103+
<Generator>MSBuild:Compile</Generator>
104+
<SubType>Designer</SubType>
105+
</Page>
106+
<Page Include="DeploySolidityProject\DeploySolidityProjectToolWindowControl.xaml">
107+
<Generator>MSBuild:Compile</Generator>
108+
<SubType>Designer</SubType>
109+
</Page>
96110
<Page Include="DialogWindowResources.xaml">
97111
<Generator>MSBuild:Compile</Generator>
98112
<SubType>Designer</SubType>

0 commit comments

Comments
 (0)