mirror of
https://github.com/sourcegit-scm/sourcegit
synced 2025-05-22 12:45:00 +00:00
feature: supports to re-order workspaces (#1261)
Signed-off-by: leo <longshuang@msn.cn>
This commit is contained in:
parent
61bc42612e
commit
3b0c57be84
2 changed files with 59 additions and 10 deletions
|
@ -9,7 +9,6 @@ namespace SourceGit.ViewModels
|
||||||
public AvaloniaList<Workspace> Workspaces
|
public AvaloniaList<Workspace> Workspaces
|
||||||
{
|
{
|
||||||
get;
|
get;
|
||||||
private set;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Workspace Selected
|
public Workspace Selected
|
||||||
|
@ -51,6 +50,36 @@ namespace SourceGit.ViewModels
|
||||||
Workspaces.Remove(_selected);
|
Workspaces.Remove(_selected);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void MoveSelectedUp()
|
||||||
|
{
|
||||||
|
if (_selected == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
var idx = Workspaces.IndexOf(_selected);
|
||||||
|
if (idx == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
Workspaces.Move(idx - 1, idx);
|
||||||
|
|
||||||
|
Preferences.Instance.Workspaces.RemoveAt(idx);
|
||||||
|
Preferences.Instance.Workspaces.Insert(idx - 1, _selected);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void MoveSelectedDown()
|
||||||
|
{
|
||||||
|
if (_selected == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
var idx = Workspaces.IndexOf(_selected);
|
||||||
|
if (idx == Workspaces.Count - 1)
|
||||||
|
return;
|
||||||
|
|
||||||
|
Workspaces.Move(idx + 1, idx);
|
||||||
|
|
||||||
|
Preferences.Instance.Workspaces.RemoveAt(idx);
|
||||||
|
Preferences.Instance.Workspaces.Insert(idx + 1, _selected);
|
||||||
|
}
|
||||||
|
|
||||||
private Workspace _selected = null;
|
private Workspace _selected = null;
|
||||||
private bool _canDeleteSelected = false;
|
private bool _canDeleteSelected = false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -79,19 +79,39 @@
|
||||||
|
|
||||||
<Rectangle Grid.Row="1" Height="1" Fill="{DynamicResource Brush.Border2}" HorizontalAlignment="Stretch" VerticalAlignment="Bottom"/>
|
<Rectangle Grid.Row="1" Height="1" Fill="{DynamicResource Brush.Border2}" HorizontalAlignment="Stretch" VerticalAlignment="Bottom"/>
|
||||||
|
|
||||||
<StackPanel Grid.Row="2" Orientation="Horizontal" Background="{DynamicResource Brush.ToolBar}">
|
<Grid Grid.Row="2" ColumnDefinitions="Auto,Auto,*,Auto,Auto" Background="{DynamicResource Brush.ToolBar}">
|
||||||
<Button Classes="icon_button" Command="{Binding Add}">
|
<Button Grid.Column="0"
|
||||||
|
Classes="icon_button"
|
||||||
|
Width="28" Height="28"
|
||||||
|
Command="{Binding Add}">
|
||||||
<Path Width="14" Height="14" Data="{StaticResource Icons.Plus}"/>
|
<Path Width="14" Height="14" Data="{StaticResource Icons.Plus}"/>
|
||||||
</Button>
|
</Button>
|
||||||
|
<Button Grid.Column="1"
|
||||||
<Rectangle Width="1" Fill="{DynamicResource Brush.Border2}" HorizontalAlignment="Left" VerticalAlignment="Stretch"/>
|
Classes="icon_button"
|
||||||
|
Width="28" Height="28"
|
||||||
<Button Classes="icon_button" Command="{Binding Delete}" IsEnabled="{Binding CanDeleteSelected}">
|
Command="{Binding Delete}"
|
||||||
|
IsEnabled="{Binding CanDeleteSelected}">
|
||||||
<Path Width="14" Height="14" Data="{StaticResource Icons.Window.Minimize}"/>
|
<Path Width="14" Height="14" Data="{StaticResource Icons.Window.Minimize}"/>
|
||||||
</Button>
|
</Button>
|
||||||
|
<Button Grid.Column="3"
|
||||||
<Rectangle Width="1" Fill="{DynamicResource Brush.Border2}" HorizontalAlignment="Left" VerticalAlignment="Stretch"/>
|
Classes="icon_button"
|
||||||
</StackPanel>
|
Width="28" Height="28"
|
||||||
|
Command="{Binding MoveSelectedUp}"
|
||||||
|
IsVisible="{Binding Selected, 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 MoveSelectedDown}"
|
||||||
|
IsVisible="{Binding Selected, Converter={x:Static ObjectConverters.IsNotNull}}">
|
||||||
|
<Path Width="14" Height="14"
|
||||||
|
Margin="0,6,0,0"
|
||||||
|
Data="{StaticResource Icons.Down}"/>
|
||||||
|
</Button>
|
||||||
|
</Grid>
|
||||||
</Grid>
|
</Grid>
|
||||||
</Border>
|
</Border>
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue