Skip to content

Commit 0e8eeb7

Browse files
committed
add DuplicateCustomAction(fixes #1632)
1 parent 7d09af1 commit 0e8eeb7

File tree

4 files changed

+59
-3
lines changed

4 files changed

+59
-3
lines changed

src/Models/CustomAction.cs

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,23 @@ public enum CustomActionControlType
2121

2222
public class CustomActionControl : ObservableObject
2323
{
24+
public CustomActionControl()
25+
{
26+
}
27+
28+
public CustomActionControl(CustomActionControl cac)
29+
{
30+
if (cac != null)
31+
{
32+
Type = cac.Type;
33+
Description = cac.Description;
34+
Label = cac.Label;
35+
Description = cac.Description;
36+
StringValue = cac.StringValue;
37+
BoolValue = cac.BoolValue;
38+
}
39+
}
40+
2441
public CustomActionControlType Type
2542
{
2643
get => _type;
@@ -60,6 +77,24 @@ public bool BoolValue
6077

6178
public class CustomAction : ObservableObject
6279
{
80+
public CustomAction()
81+
{
82+
}
83+
84+
public CustomAction(CustomAction action)
85+
{
86+
if (action != null)
87+
{
88+
Name = action.Name;
89+
Scope = action.Scope;
90+
Executable = action.Executable;
91+
Arguments = action.Arguments;
92+
WaitForExit = action.WaitForExit;
93+
foreach (var control in action.Controls)
94+
Controls.Add(new CustomActionControl(control));
95+
}
96+
}
97+
6398
public string Name
6499
{
65100
get => _name;

src/Models/RepositorySettings.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -410,6 +410,16 @@ public CustomAction AddNewCustomAction()
410410
return act;
411411
}
412412

413+
public CustomAction DuplicateCustomAction(CustomAction baseAct)
414+
{
415+
var act = new CustomAction(baseAct)
416+
{
417+
Name = baseAct.Name + "(Duplicated)"
418+
};
419+
CustomActions.Add(act);
420+
return act;
421+
}
422+
413423
public void RemoveCustomAction(CustomAction act)
414424
{
415425
if (act != null)

src/ViewModels/RepositoryConfigure.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,11 @@ public void RemoveSelectedCustomAction()
238238
SelectedCustomAction = null;
239239
}
240240

241+
public void DuplicateSelectedCustomAction()
242+
{
243+
SelectedCustomAction = _repo.Settings.DuplicateCustomAction(_selectedCustomAction);
244+
}
245+
241246
public void MoveSelectedCustomActionUp()
242247
{
243248
if (_selectedCustomAction != null)

src/Views/RepositoryConfigure.axaml

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -424,7 +424,7 @@
424424

425425
<Rectangle Grid.Row="1" Height="1" Fill="{DynamicResource Brush.Border2}" HorizontalAlignment="Stretch" VerticalAlignment="Bottom"/>
426426

427-
<Grid Grid.Row="2" ColumnDefinitions="Auto,Auto,*,Auto,Auto" Background="{DynamicResource Brush.ToolBar}">
427+
<Grid Grid.Row="2" ColumnDefinitions="Auto,Auto,Auto,*,Auto,Auto" Background="{DynamicResource Brush.ToolBar}">
428428
<Button Grid.Column="0"
429429
Classes="icon_button"
430430
Width="28" Height="28"
@@ -437,14 +437,20 @@
437437
Command="{Binding RemoveSelectedCustomAction}">
438438
<Path Width="14" Height="14" Data="{StaticResource Icons.Minus}"/>
439439
</Button>
440-
<Button Grid.Column="3"
440+
<Button Grid.Column="2"
441+
Classes="icon_button"
442+
Width="28" Height="28"
443+
Command="{Binding DuplicateSelectedCustomAction}">
444+
<Path Width="14" Height="14" Data="{StaticResource Icons.Copy}"/>
445+
</Button>
446+
<Button Grid.Column="4"
441447
Classes="icon_button"
442448
Width="28" Height="28"
443449
Command="{Binding MoveSelectedCustomActionUp}"
444450
IsVisible="{Binding SelectedCustomAction, Converter={x:Static ObjectConverters.IsNotNull}}">
445451
<Path Width="14" Height="14" Margin="0,6,0,0" Data="{StaticResource Icons.Up}"/>
446452
</Button>
447-
<Button Grid.Column="4"
453+
<Button Grid.Column="5"
448454
Classes="icon_button"
449455
Width="28" Height="28"
450456
Command="{Binding MoveSelectedCustomActionDown}"

0 commit comments

Comments
 (0)