Skip to content

Commit d838f60

Browse files
committed
add DuplicateCustomAction(fixes sourcegit-scm#1632)
1 parent 3909079 commit d838f60

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
@@ -22,6 +22,23 @@ public enum CustomActionControlType
2222

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

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

src/Models/RepositorySettings.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -416,6 +416,16 @@ public CustomAction AddNewCustomAction()
416416
return act;
417417
}
418418

419+
public CustomAction DuplicateCustomAction(CustomAction baseAct)
420+
{
421+
var act = new CustomAction(baseAct)
422+
{
423+
Name = baseAct.Name + "(Duplicated)"
424+
};
425+
CustomActions.Add(act);
426+
return act;
427+
}
428+
419429
public void RemoveCustomAction(CustomAction act)
420430
{
421431
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)