mirror of
https://github.com/sourcegit-scm/sourcegit
synced 2025-06-15 07:35:04 +00:00
feature: supports re-order custom actions (#1346)
Signed-off-by: leo <longshuang@msn.cn>
This commit is contained in:
parent
ee2e7d0127
commit
98041c803e
5 changed files with 98 additions and 18 deletions
|
@ -453,5 +453,19 @@ namespace SourceGit.Models
|
|||
if (act != null)
|
||||
CustomActions.Remove(act);
|
||||
}
|
||||
|
||||
public void MoveCustomActionUp(CustomAction act)
|
||||
{
|
||||
var idx = CustomActions.IndexOf(act);
|
||||
if (idx > 0)
|
||||
CustomActions.Move(idx - 1, idx);
|
||||
}
|
||||
|
||||
public void MoveCustomActionDown(CustomAction act)
|
||||
{
|
||||
var idx = CustomActions.IndexOf(act);
|
||||
if (idx < CustomActions.Count - 1)
|
||||
CustomActions.Move(idx + 1, idx);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -304,6 +304,18 @@ namespace SourceGit.ViewModels
|
|||
SelectedCustomAction = null;
|
||||
}
|
||||
|
||||
public void MoveSelectedCustomActionUp()
|
||||
{
|
||||
if (_selectedCustomAction != null)
|
||||
_repo.Settings.MoveCustomActionUp(_selectedCustomAction);
|
||||
}
|
||||
|
||||
public void MoveSelectedCustomActionDown()
|
||||
{
|
||||
if (_selectedCustomAction != null)
|
||||
_repo.Settings.MoveCustomActionDown(_selectedCustomAction);
|
||||
}
|
||||
|
||||
public void Save()
|
||||
{
|
||||
SetIfChanged("user.name", UserName, "");
|
||||
|
|
|
@ -583,19 +583,34 @@
|
|||
|
||||
<Rectangle Grid.Row="1" Height="1" Fill="{DynamicResource Brush.Border2}" HorizontalAlignment="Stretch" VerticalAlignment="Bottom"/>
|
||||
|
||||
<StackPanel Grid.Row="2" Orientation="Horizontal" Background="{DynamicResource Brush.ToolBar}">
|
||||
<Button Classes="icon_button" Click="OnAddCustomAction">
|
||||
<Grid Grid.Row="2" ColumnDefinitions="Auto,Auto,*,Auto,Auto" Background="{DynamicResource Brush.ToolBar}">
|
||||
<Button Grid.Column="0"
|
||||
Classes="icon_button"
|
||||
Width="28" Height="28"
|
||||
Click="OnAddCustomAction">
|
||||
<Path Width="14" Height="14" Data="{StaticResource Icons.Plus}"/>
|
||||
</Button>
|
||||
|
||||
<Rectangle Width="1" Fill="{DynamicResource Brush.Border2}" HorizontalAlignment="Left" VerticalAlignment="Stretch"/>
|
||||
|
||||
<Button Classes="icon_button" Click="OnRemoveSelectedCustomAction">
|
||||
<Button Grid.Column="1"
|
||||
Classes="icon_button"
|
||||
Width="28" Height="28"
|
||||
Click="OnRemoveSelectedCustomAction">
|
||||
<Path Width="14" Height="14" Data="{StaticResource Icons.Window.Minimize}"/>
|
||||
</Button>
|
||||
|
||||
<Rectangle Width="1" Fill="{DynamicResource Brush.Border2}" HorizontalAlignment="Left" VerticalAlignment="Stretch"/>
|
||||
</StackPanel>
|
||||
<Button Grid.Column="3"
|
||||
Classes="icon_button"
|
||||
Width="28" Height="28"
|
||||
Click="OnMoveSelectedCustomActionUp"
|
||||
IsVisible="{Binding #ThisControl.SelectedCustomAction, Converter={x:Static ObjectConverters.IsNotNull}}">
|
||||
<Path Width="14" Height="14" Margin="0,6,0,0" Data="{StaticResource Icons.Up}"/>
|
||||
</Button>
|
||||
<Button Grid.Column="4"
|
||||
Classes="icon_button"
|
||||
Width="28" Height="28"
|
||||
Click="OnMoveSelectedCustomActionDown"
|
||||
IsVisible="{Binding #ThisControl.SelectedCustomAction, Converter={x:Static ObjectConverters.IsNotNull}}">
|
||||
<Path Width="14" Height="14" Margin="0,6,0,0" Data="{StaticResource Icons.Down}"/>
|
||||
</Button>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Border>
|
||||
|
||||
|
|
|
@ -415,6 +415,30 @@ namespace SourceGit.Views
|
|||
e.Handled = true;
|
||||
}
|
||||
|
||||
private void OnMoveSelectedCustomActionUp(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (SelectedCustomAction == null)
|
||||
return;
|
||||
|
||||
var idx = ViewModels.Preferences.Instance.CustomActions.IndexOf(SelectedCustomAction);
|
||||
if (idx > 0)
|
||||
ViewModels.Preferences.Instance.CustomActions.Move(idx - 1, idx);
|
||||
|
||||
e.Handled = true;
|
||||
}
|
||||
|
||||
private void OnMoveSelectedCustomActionDown(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (SelectedCustomAction == null)
|
||||
return;
|
||||
|
||||
var idx = ViewModels.Preferences.Instance.CustomActions.IndexOf(SelectedCustomAction);
|
||||
if (idx < ViewModels.Preferences.Instance.CustomActions.Count - 1)
|
||||
ViewModels.Preferences.Instance.CustomActions.Move(idx + 1, idx);
|
||||
|
||||
e.Handled = true;
|
||||
}
|
||||
|
||||
private void UpdateGitVersion()
|
||||
{
|
||||
GitVersion = Native.OS.GitVersionString;
|
||||
|
|
|
@ -417,19 +417,34 @@
|
|||
|
||||
<Rectangle Grid.Row="1" Height="1" Fill="{DynamicResource Brush.Border2}" HorizontalAlignment="Stretch" VerticalAlignment="Bottom"/>
|
||||
|
||||
<StackPanel Grid.Row="2" Orientation="Horizontal" Background="{DynamicResource Brush.ToolBar}">
|
||||
<Button Classes="icon_button" Command="{Binding AddNewCustomAction}">
|
||||
<Grid Grid.Row="2" ColumnDefinitions="Auto,Auto,*,Auto,Auto" Background="{DynamicResource Brush.ToolBar}">
|
||||
<Button Grid.Column="0"
|
||||
Classes="icon_button"
|
||||
Width="28" Height="28"
|
||||
Command="{Binding AddNewCustomAction}">
|
||||
<Path Width="14" Height="14" Data="{StaticResource Icons.Plus}"/>
|
||||
</Button>
|
||||
|
||||
<Rectangle Width="1" Fill="{DynamicResource Brush.Border2}" HorizontalAlignment="Left" VerticalAlignment="Stretch"/>
|
||||
|
||||
<Button Classes="icon_button" Command="{Binding RemoveSelectedCustomAction}">
|
||||
<Button Grid.Column="1"
|
||||
Classes="icon_button"
|
||||
Width="28" Height="28"
|
||||
Command="{Binding RemoveSelectedCustomAction}">
|
||||
<Path Width="14" Height="14" Data="{StaticResource Icons.Window.Minimize}"/>
|
||||
</Button>
|
||||
|
||||
<Rectangle Width="1" Fill="{DynamicResource Brush.Border2}" HorizontalAlignment="Left" VerticalAlignment="Stretch"/>
|
||||
</StackPanel>
|
||||
<Button Grid.Column="3"
|
||||
Classes="icon_button"
|
||||
Width="28" Height="28"
|
||||
Command="{Binding MoveSelectedCustomActionUp}"
|
||||
IsVisible="{Binding SelectedCustomAction, Converter={x:Static ObjectConverters.IsNotNull}}">
|
||||
<Path Width="14" Height="14" Margin="0,6,0,0" Data="{StaticResource Icons.Up}"/>
|
||||
</Button>
|
||||
<Button Grid.Column="4"
|
||||
Classes="icon_button"
|
||||
Width="28" Height="28"
|
||||
Command="{Binding MoveSelectedCustomActionDown}"
|
||||
IsVisible="{Binding SelectedCustomAction, Converter={x:Static ObjectConverters.IsNotNull}}">
|
||||
<Path Width="14" Height="14" Margin="0,6,0,0" Data="{StaticResource Icons.Down}"/>
|
||||
</Button>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Border>
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue