mirror of
https://github.com/sourcegit-scm/sourcegit.git
synced 2024-11-01 13:13:21 -07:00
feature<Launcher>: change style of tabs in title bar; bookmark color for repository
This commit is contained in:
parent
7e01792a37
commit
a2254ae578
5 changed files with 232 additions and 87 deletions
52
src/Converters/IntToRepoColor.cs
Normal file
52
src/Converters/IntToRepoColor.cs
Normal file
|
@ -0,0 +1,52 @@
|
||||||
|
using System;
|
||||||
|
using System.Globalization;
|
||||||
|
using System.Windows;
|
||||||
|
using System.Windows.Data;
|
||||||
|
using System.Windows.Media;
|
||||||
|
|
||||||
|
namespace SourceGit.Converters {
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Integer to color.
|
||||||
|
/// </summary>
|
||||||
|
public class IntToRepoColor : IValueConverter {
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// All supported colors.
|
||||||
|
/// </summary>
|
||||||
|
public static Brush[] Colors = new Brush[] {
|
||||||
|
Brushes.White,
|
||||||
|
Brushes.Red,
|
||||||
|
Brushes.Orange,
|
||||||
|
Brushes.Yellow,
|
||||||
|
Brushes.ForestGreen,
|
||||||
|
Brushes.Purple,
|
||||||
|
Brushes.DeepSkyBlue,
|
||||||
|
Brushes.Magenta,
|
||||||
|
};
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Implement IValueConverter.Convert
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="value"></param>
|
||||||
|
/// <param name="targetType"></param>
|
||||||
|
/// <param name="parameter"></param>
|
||||||
|
/// <param name="culture"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) {
|
||||||
|
return Colors[((int)value) % Colors.Length];
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Implement IValueConverter.ConvertBack
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="value"></param>
|
||||||
|
/// <param name="targetType"></param>
|
||||||
|
/// <param name="parameter"></param>
|
||||||
|
/// <param name="culture"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) {
|
||||||
|
return ((Thickness)value).Left;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -39,6 +39,10 @@ namespace SourceGit.Git {
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string GroupId { get; set; }
|
public string GroupId { get; set; }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
/// Custom color.
|
||||||
|
/// </summary>
|
||||||
|
public int Color { get; set; } = 0;
|
||||||
|
/// <summary>
|
||||||
/// Last open time(File time format).
|
/// Last open time(File time format).
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public long LastOpenTime { get; set; }
|
public long LastOpenTime { get; set; }
|
||||||
|
|
|
@ -57,7 +57,7 @@
|
||||||
</Grid.ColumnDefinitions>
|
</Grid.ColumnDefinitions>
|
||||||
|
|
||||||
<ContentPresenter Name="Icon" Grid.Column="0" Margin="6,0" VerticalAlignment="Center" ContentSource="Icon"/>
|
<ContentPresenter Name="Icon" Grid.Column="0" Margin="6,0" VerticalAlignment="Center" ContentSource="Icon"/>
|
||||||
<ContentPresenter Name="HeadHost" Grid.Column="1" ContentSource="Header" VerticalAlignment="Center"/>
|
<ContentPresenter Name="HeadHost" Grid.Column="1" Margin="0,0,8,0" ContentSource="Header" VerticalAlignment="Center"/>
|
||||||
<Path Grid.Column="2" Width="8" Height="8" Style="{DynamicResource Style.Icon}" Data="M 0 0 L 0 7 L 4 3.5 Z"/>
|
<Path Grid.Column="2" Width="8" Height="8" Style="{DynamicResource Style.Icon}" Data="M 0 0 L 0 7 L 4 3.5 Z"/>
|
||||||
<Popup Name="Popup" Placement="Right" HorizontalOffset="-2" IsOpen="{TemplateBinding IsSubmenuOpen}" AllowsTransparency="True" Focusable="False" PopupAnimation="Fade">
|
<Popup Name="Popup" Placement="Right" HorizontalOffset="-2" IsOpen="{TemplateBinding IsSubmenuOpen}" AllowsTransparency="True" Focusable="False" PopupAnimation="Fade">
|
||||||
<Border Name="SubmenuBorder" SnapsToDevicePixels="True" Background="{DynamicResource Brush.BG1}" BorderBrush="{DynamicResource Brush.Border1}" BorderThickness="1">
|
<Border Name="SubmenuBorder" SnapsToDevicePixels="True" Background="{DynamicResource Brush.BG1}" BorderBrush="{DynamicResource Brush.Border1}" BorderThickness="1">
|
||||||
|
|
|
@ -5,6 +5,8 @@
|
||||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
xmlns:source="clr-namespace:SourceGit"
|
xmlns:source="clr-namespace:SourceGit"
|
||||||
|
xmlns:local="clr-namespace:SourceGit.UI"
|
||||||
|
xmlns:converters="clr-namespace:SourceGit.Converters"
|
||||||
mc:Ignorable="d"
|
mc:Ignorable="d"
|
||||||
MinWidth="800" MinHeight="600"
|
MinWidth="800" MinHeight="600"
|
||||||
Title="Source Git"
|
Title="Source Git"
|
||||||
|
@ -62,41 +64,82 @@
|
||||||
<Setter Property="Template">
|
<Setter Property="Template">
|
||||||
<Setter.Value>
|
<Setter.Value>
|
||||||
<ControlTemplate TargetType="{x:Type TabControl}">
|
<ControlTemplate TargetType="{x:Type TabControl}">
|
||||||
<StackPanel Orientation="Horizontal"
|
<StackPanel Orientation="Horizontal" x:Name="HeaderPanel" Margin="6,4,0,0" IsItemsHost="True" SnapsToDevicePixels="True" KeyboardNavigation.TabIndex="1"/>
|
||||||
x:Name="HeaderPanel"
|
|
||||||
Margin="6,4,0,0"
|
|
||||||
IsItemsHost="True"
|
|
||||||
SnapsToDevicePixels="True"
|
|
||||||
KeyboardNavigation.TabIndex="1"/>
|
|
||||||
</ControlTemplate>
|
</ControlTemplate>
|
||||||
</Setter.Value>
|
</Setter.Value>
|
||||||
</Setter>
|
</Setter>
|
||||||
</Style>
|
</Style>
|
||||||
</TabControl.Style>
|
</TabControl.Style>
|
||||||
|
|
||||||
|
<TabControl.Resources>
|
||||||
|
<converters:IntToRepoColor x:Key="IntToRepoColor"/>
|
||||||
|
|
||||||
|
<DataTemplate DataType="{x:Type local:Launcher+ManagerTab}">
|
||||||
|
<Path Width="14" Height="14" Margin="12,0" Fill="#FFF05133" Style="{StaticResource Style.Icon}" Data="{StaticResource Icon.Home}"/>
|
||||||
|
</DataTemplate>
|
||||||
|
|
||||||
|
<DataTemplate DataType="{x:Type local:Launcher+RepoTab}">
|
||||||
|
<Grid MinWidth="72" Margin="12,0">
|
||||||
|
<Grid.ColumnDefinitions>
|
||||||
|
<ColumnDefinition Width="Auto"/>
|
||||||
|
<ColumnDefinition Width="Auto"/>
|
||||||
|
<ColumnDefinition Width="*" MinWidth="6"/>
|
||||||
|
<ColumnDefinition Width="Auto"/>
|
||||||
|
</Grid.ColumnDefinitions>
|
||||||
|
|
||||||
|
<Path
|
||||||
|
Grid.Column="0"
|
||||||
|
Width="12" Height="12"
|
||||||
|
Fill="{Binding Color, Converter={StaticResource IntToRepoColor}}"
|
||||||
|
Style="{StaticResource Style.Icon}"
|
||||||
|
Data="{StaticResource Icon.Git}"/>
|
||||||
|
|
||||||
|
<Label
|
||||||
|
Grid.Column="1"
|
||||||
|
Content="{Binding Title}"
|
||||||
|
Foreground="{StaticResource Brush.FG}" FontFamily="Consolas" FontWeight="Bold"/>
|
||||||
|
|
||||||
|
<Button Grid.Column="3" Click="CloseRepo" ToolTip="CLOSE">
|
||||||
|
<Path
|
||||||
|
Width="8" Height="8"
|
||||||
|
Fill="{StaticResource Brush.FG}"
|
||||||
|
Style="{StaticResource Style.Icon}"
|
||||||
|
Data="{StaticResource Icon.Close}"/>
|
||||||
|
</Button>
|
||||||
|
</Grid>
|
||||||
|
</DataTemplate>
|
||||||
|
</TabControl.Resources>
|
||||||
|
|
||||||
<TabControl.ItemContainerStyle>
|
<TabControl.ItemContainerStyle>
|
||||||
<Style TargetType="{x:Type TabItem}">
|
<Style TargetType="{x:Type TabItem}">
|
||||||
<Setter Property="AllowDrop" Value="{Binding AllowDragDrop}"/>
|
<Setter Property="AllowDrop" Value="{Binding IsRepo}"/>
|
||||||
<Setter Property="IsSelected" Value="{Binding IsActive, Mode=TwoWay}"/>
|
<Setter Property="IsSelected" Value="{Binding IsActive, Mode=TwoWay}"/>
|
||||||
<Setter Property="Margin" Value="0"/>
|
<Setter Property="Margin" Value="0"/>
|
||||||
<Setter Property="Padding" Value="0"/>
|
<Setter Property="Padding" Value="0"/>
|
||||||
<Setter Property="Template">
|
<Setter Property="Template">
|
||||||
<Setter.Value>
|
<Setter.Value>
|
||||||
<ControlTemplate TargetType="{x:Type TabItem}">
|
<ControlTemplate TargetType="{x:Type TabItem}">
|
||||||
<Grid x:Name="Container" Opacity=".7" SnapsToDevicePixels="True" WindowChrome.IsHitTestVisibleInChrome="True">
|
<Grid SnapsToDevicePixels="True" WindowChrome.IsHitTestVisibleInChrome="True" ToolTip="{Binding Tooltip}">
|
||||||
<Border x:Name="BG" SnapsToDevicePixels="True" Background="Transparent" BorderThickness="0" BorderBrush="{StaticResource Brush.BG3}" CornerRadius="4,4,0,0">
|
<Border x:Name="BG" Margin="-1,0" SnapsToDevicePixels="True" Background="Transparent" BorderThickness="0" BorderBrush="{StaticResource Brush.BG3}" CornerRadius="4,4,0,0">
|
||||||
<Border.Effect>
|
<Border.Effect>
|
||||||
<DropShadowEffect ShadowDepth="0" Opacity=".5"/>
|
<DropShadowEffect ShadowDepth="0" Opacity=".5"/>
|
||||||
</Border.Effect>
|
</Border.Effect>
|
||||||
</Border>
|
</Border>
|
||||||
|
|
||||||
|
<Rectangle
|
||||||
|
x:Name="Splitter"
|
||||||
|
HorizontalAlignment="Left"
|
||||||
|
Width="1" Height="16"
|
||||||
|
Fill="{StaticResource Brush.FG2}"
|
||||||
|
Visibility="Hidden"/>
|
||||||
|
|
||||||
<Path
|
<Path
|
||||||
x:Name="CornerLeft"
|
x:Name="CornerLeft"
|
||||||
Width="6"
|
Width="6"
|
||||||
Height="6"
|
Height="6"
|
||||||
HorizontalAlignment="Left"
|
HorizontalAlignment="Left"
|
||||||
VerticalAlignment="Bottom"
|
VerticalAlignment="Bottom"
|
||||||
Margin="-5,0,0,0"
|
Margin="-6,0,0,0"
|
||||||
Data="M 0,6 L 6,6 6,0 C 6,0 6,6 0,6 Z"
|
Data="M 0,6 L 6,6 6,0 C 6,0 6,6 0,6 Z"
|
||||||
Fill="Transparent"/>
|
Fill="Transparent"/>
|
||||||
|
|
||||||
|
@ -106,44 +149,50 @@
|
||||||
Height="6"
|
Height="6"
|
||||||
HorizontalAlignment="Right"
|
HorizontalAlignment="Right"
|
||||||
VerticalAlignment="Bottom"
|
VerticalAlignment="Bottom"
|
||||||
Margin="0,0,-5,0"
|
Margin="0,0,-6,0"
|
||||||
Data="M 0,0 L 0,6 6,6 C 6,6 0,6 0,0 Z"
|
Data="M 0,0 L 0,6 6,6 C 6,6 0,6 0,0 Z"
|
||||||
Fill="Transparent"/>
|
Fill="Transparent"/>
|
||||||
|
|
||||||
<StackPanel Orientation="Horizontal" Margin="12,0" VerticalAlignment="Center">
|
|
||||||
<Path Grid.Column="0" Width="14" Height="14" x:Name="Icon" Style="{StaticResource Style.Icon}" Data="{StaticResource Icon.Git}"/>
|
|
||||||
|
|
||||||
<ContentPresenter
|
<ContentPresenter
|
||||||
x:Name="ContentSite"
|
x:Name="ContentSite"
|
||||||
VerticalAlignment="Center" HorizontalAlignment="Center"
|
VerticalAlignment="Center"
|
||||||
TextElement.Foreground="{DynamicResource Brush.FG}"
|
|
||||||
TextElement.FontWeight="Bold"
|
|
||||||
ContentSource="Header"
|
ContentSource="Header"
|
||||||
Margin="8,0,0,0"
|
Opacity=".7"
|
||||||
RecognizesAccessKey="True"/>
|
RecognizesAccessKey="True"/>
|
||||||
</StackPanel>
|
|
||||||
</Grid>
|
</Grid>
|
||||||
<ControlTemplate.Triggers>
|
<ControlTemplate.Triggers>
|
||||||
<Trigger Property="IsSelected" Value="True">
|
<Trigger Property="IsSelected" Value="True">
|
||||||
|
<Setter Property="Panel.ZIndex" Value="2"/>
|
||||||
<Setter TargetName="BG" Property="Background" Value="{DynamicResource Brush.BG1}"/>
|
<Setter TargetName="BG" Property="Background" Value="{DynamicResource Brush.BG1}"/>
|
||||||
<Setter TargetName="BG" Property="BorderThickness" Value="1,1,1,0"/>
|
<Setter TargetName="BG" Property="BorderThickness" Value="1,1,1,0"/>
|
||||||
<Setter TargetName="Container" Property="Opacity" Value="1"/>
|
|
||||||
<Setter TargetName="CornerLeft" Property="Fill" Value="{StaticResource Brush.BG1}"/>
|
<Setter TargetName="CornerLeft" Property="Fill" Value="{StaticResource Brush.BG1}"/>
|
||||||
<Setter TargetName="CornerRight" Property="Fill" Value="{StaticResource Brush.BG1}"/>
|
<Setter TargetName="CornerRight" Property="Fill" Value="{StaticResource Brush.BG1}"/>
|
||||||
|
<Setter TargetName="ContentSite" Property="Opacity" Value="1"/>
|
||||||
</Trigger>
|
</Trigger>
|
||||||
<Trigger Property="AllowDrop" Value="False">
|
|
||||||
<Setter TargetName="Icon" Property="Data" Value="{StaticResource Icon.Home}"/>
|
<Trigger Property="IsSelected" Value="False">
|
||||||
|
<Setter Property="Panel.ZIndex" Value="-1"/>
|
||||||
</Trigger>
|
</Trigger>
|
||||||
|
|
||||||
<MultiTrigger>
|
<MultiTrigger>
|
||||||
<MultiTrigger.Conditions>
|
<MultiTrigger.Conditions>
|
||||||
<Condition Property="IsSelected" Value="False"/>
|
<Condition Property="IsSelected" Value="False"/>
|
||||||
<Condition Property="IsMouseOver" Value="True"/>
|
<Condition Property="IsMouseOver" Value="True"/>
|
||||||
</MultiTrigger.Conditions>
|
</MultiTrigger.Conditions>
|
||||||
<Setter Property="Panel.ZIndex" Value="-1"/>
|
<Setter Property="Panel.ZIndex" Value="1"/>
|
||||||
<Setter TargetName="BG" Property="Background" Value="{DynamicResource Brush.BG5}"/>
|
<Setter TargetName="BG" Property="Background" Value="{DynamicResource Brush.BG5}"/>
|
||||||
<Setter TargetName="CornerLeft" Property="Fill" Value="{StaticResource Brush.BG5}"/>
|
<Setter TargetName="CornerLeft" Property="Fill" Value="{StaticResource Brush.BG5}"/>
|
||||||
<Setter TargetName="CornerRight" Property="Fill" Value="{StaticResource Brush.BG5}"/>
|
<Setter TargetName="CornerRight" Property="Fill" Value="{StaticResource Brush.BG5}"/>
|
||||||
</MultiTrigger>
|
</MultiTrigger>
|
||||||
|
|
||||||
|
<MultiTrigger>
|
||||||
|
<MultiTrigger.Conditions>
|
||||||
|
<Condition Property="IsSelected" Value="False"/>
|
||||||
|
<Condition Property="IsMouseOver" Value="False"/>
|
||||||
|
<Condition Property="AllowDrop" Value="True"/>
|
||||||
|
</MultiTrigger.Conditions>
|
||||||
|
<Setter TargetName="Splitter" Property="Visibility" Value="Visible"/>
|
||||||
|
</MultiTrigger>
|
||||||
</ControlTemplate.Triggers>
|
</ControlTemplate.Triggers>
|
||||||
</ControlTemplate>
|
</ControlTemplate>
|
||||||
</Setter.Value>
|
</Setter.Value>
|
||||||
|
@ -154,16 +203,6 @@
|
||||||
<EventSetter Event="ContextMenuOpening" Handler="TabsContextMenuOpening"/>
|
<EventSetter Event="ContextMenuOpening" Handler="TabsContextMenuOpening"/>
|
||||||
</Style>
|
</Style>
|
||||||
</TabControl.ItemContainerStyle>
|
</TabControl.ItemContainerStyle>
|
||||||
|
|
||||||
<TabControl.ItemTemplate>
|
|
||||||
<DataTemplate>
|
|
||||||
<TextBlock Grid.Column="1" Text="{Binding Title}" Foreground="{StaticResource Brush.FG}" FontWeight="Bold">
|
|
||||||
<TextBlock.ToolTip>
|
|
||||||
<ToolTip Content="{Binding Tooltip}" FontWeight="Normal"/>
|
|
||||||
</TextBlock.ToolTip>
|
|
||||||
</TextBlock>
|
|
||||||
</DataTemplate>
|
|
||||||
</TabControl.ItemTemplate>
|
|
||||||
</TabControl>
|
</TabControl>
|
||||||
</ScrollViewer>
|
</ScrollViewer>
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
using System;
|
|
||||||
using System.Collections.ObjectModel;
|
using System.Collections.ObjectModel;
|
||||||
|
using System.ComponentModel;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Text.Json;
|
using System.Text.Json;
|
||||||
|
@ -8,6 +8,7 @@ using System.Threading.Tasks;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using System.Windows.Controls;
|
using System.Windows.Controls;
|
||||||
using System.Windows.Input;
|
using System.Windows.Input;
|
||||||
|
using System.Windows.Media;
|
||||||
|
|
||||||
namespace SourceGit.UI {
|
namespace SourceGit.UI {
|
||||||
|
|
||||||
|
@ -19,13 +20,48 @@ namespace SourceGit.UI {
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Tab data.
|
/// Tab data.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class Tab {
|
public class Tab : INotifyPropertyChanged {
|
||||||
public string Title { get; set; }
|
public string Title { get; set; }
|
||||||
public string Tooltip { get; set; }
|
public string Tooltip { get; set; }
|
||||||
public bool AllowDragDrop { get; set; }
|
|
||||||
public bool IsActive { get; set; }
|
public bool IsActive { get; set; }
|
||||||
public Git.Repository Repo { get; set; }
|
public Git.Repository Repo { get; set; }
|
||||||
public object Page { get; set; }
|
public object Page { get; set; }
|
||||||
|
public bool IsRepo => Repo != null;
|
||||||
|
public int Color {
|
||||||
|
get { return Repo == null ? 0 : Repo.Color; }
|
||||||
|
set {
|
||||||
|
if (Repo == null || Repo.Color == value) return;
|
||||||
|
Repo.Color = value;
|
||||||
|
PropertyChanged.Invoke(this, new PropertyChangedEventArgs("Color"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public event PropertyChangedEventHandler PropertyChanged;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Manager tab
|
||||||
|
/// </summary>
|
||||||
|
public class ManagerTab : Tab {
|
||||||
|
public ManagerTab() {
|
||||||
|
Title = "HOME";
|
||||||
|
Tooltip = "Repositories Manager";
|
||||||
|
IsActive = true;
|
||||||
|
Page = new Manager();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Repository tab.
|
||||||
|
/// </summary>
|
||||||
|
public class RepoTab : Tab {
|
||||||
|
public RepoTab(Git.Repository repo, Dashboard page) {
|
||||||
|
Title = repo.Parent == null ? repo.Name : $"{repo.Parent.Name} : {repo.Name}";
|
||||||
|
Tooltip = repo.Path;
|
||||||
|
Repo = repo;
|
||||||
|
IsActive = false;
|
||||||
|
Page = page;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -42,16 +78,9 @@ namespace SourceGit.UI {
|
||||||
/// Constructor
|
/// Constructor
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public Launcher() {
|
public Launcher() {
|
||||||
Tabs.Add(new Tab() {
|
Tabs.Add(new ManagerTab());
|
||||||
Title = "HOME",
|
|
||||||
Tooltip = "Repositories Manager",
|
|
||||||
AllowDragDrop = false,
|
|
||||||
Page = new Manager(),
|
|
||||||
});
|
|
||||||
|
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
openedTabs.SelectedItem = Tabs[0];
|
openedTabs.SelectedItem = Tabs[0];
|
||||||
|
|
||||||
if (App.Preference.CheckUpdate) Task.Run(CheckUpdate);
|
if (App.Preference.CheckUpdate) Task.Run(CheckUpdate);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -69,16 +98,8 @@ namespace SourceGit.UI {
|
||||||
}
|
}
|
||||||
|
|
||||||
repo.Open();
|
repo.Open();
|
||||||
|
|
||||||
var page = new Dashboard(repo);
|
var page = new Dashboard(repo);
|
||||||
var tab = new Tab() {
|
var tab = new RepoTab(repo, page);
|
||||||
Title = repo.Parent == null ? repo.Name : $"{repo.Parent.Name} : {repo.Name}",
|
|
||||||
Tooltip = repo.Path,
|
|
||||||
AllowDragDrop = true,
|
|
||||||
Repo = repo,
|
|
||||||
Page = page,
|
|
||||||
};
|
|
||||||
|
|
||||||
repo.SetPopupManager(page.popupManager);
|
repo.SetPopupManager(page.popupManager);
|
||||||
Tabs.Add(tab);
|
Tabs.Add(tab);
|
||||||
openedTabs.SelectedItem = tab;
|
openedTabs.SelectedItem = tab;
|
||||||
|
@ -113,40 +134,38 @@ namespace SourceGit.UI {
|
||||||
|
|
||||||
#region LAYOUT_CONTENT
|
#region LAYOUT_CONTENT
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Context menu for tab items.
|
/// Close repository.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="sender"></param>
|
/// <param name="sender"></param>
|
||||||
/// <param name="e"></param>
|
/// <param name="e"></param>
|
||||||
private void TabsContextMenuOpening(object sender, ContextMenuEventArgs ev) {
|
private void CloseRepo(object sender, RoutedEventArgs e) {
|
||||||
var tab = (sender as TabItem).DataContext as Tab;
|
var tab = (sender as Button).DataContext as Tab;
|
||||||
if (tab == null) {
|
if (tab == null || tab.Repo == null) {
|
||||||
ev.Handled = true;
|
e.Handled = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var repo = tab.Repo;
|
|
||||||
if (repo == null) {
|
|
||||||
ev.Handled = true;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
var close = new MenuItem();
|
|
||||||
close.Header = "Close";
|
|
||||||
close.Click += (o, e) => {
|
|
||||||
Tabs.Remove(tab);
|
Tabs.Remove(tab);
|
||||||
|
|
||||||
tab.Page = null;
|
tab.Page = null;
|
||||||
tab.Repo.RemovePopup();
|
tab.Repo.RemovePopup();
|
||||||
tab.Repo.Close();
|
tab.Repo.Close();
|
||||||
tab.Repo = null;
|
tab.Repo = null;
|
||||||
};
|
}
|
||||||
|
|
||||||
var copyPath = new MenuItem();
|
/// <summary>
|
||||||
copyPath.Header = "Copy Path";
|
/// Context menu for tab items.
|
||||||
copyPath.Click += (o, e) => {
|
/// </summary>
|
||||||
Clipboard.SetText(repo.Path);
|
/// <param name="sender"></param>
|
||||||
e.Handled = true;
|
/// <param name="e"></param>
|
||||||
};
|
private void TabsContextMenuOpening(object sender, ContextMenuEventArgs ev) {
|
||||||
|
var tab = (sender as TabItem).DataContext as Tab;
|
||||||
|
if (tab == null || tab.Repo == null) {
|
||||||
|
ev.Handled = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var repo = tab.Repo;
|
||||||
|
|
||||||
var refresh = new MenuItem();
|
var refresh = new MenuItem();
|
||||||
refresh.Header = "Refresh";
|
refresh.Header = "Refresh";
|
||||||
|
@ -155,11 +174,39 @@ namespace SourceGit.UI {
|
||||||
e.Handled = true;
|
e.Handled = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
var bookmark = new MenuItem();
|
||||||
|
bookmark.Header = "Bookmark";
|
||||||
|
for (int i = 0; i < Converters.IntToRepoColor.Colors.Length; i++) {
|
||||||
|
var icon = new System.Windows.Shapes.Path();
|
||||||
|
icon.Style = FindResource("Style.Icon") as Style;
|
||||||
|
icon.Data = Geometry.Parse("M 0,0 A 180,180 180 1 1 1,1 Z");
|
||||||
|
icon.Fill = Converters.IntToRepoColor.Colors[i];
|
||||||
|
icon.Width = 12;
|
||||||
|
|
||||||
|
var mark = new MenuItem();
|
||||||
|
mark.Icon = icon;
|
||||||
|
mark.Header = $"{i + 1}";
|
||||||
|
|
||||||
|
var refIdx = i;
|
||||||
|
mark.Click += (o, e) => {
|
||||||
|
tab.Color = refIdx;
|
||||||
|
e.Handled = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
bookmark.Items.Add(mark);
|
||||||
|
}
|
||||||
|
|
||||||
|
var copyPath = new MenuItem();
|
||||||
|
copyPath.Header = "Copy path";
|
||||||
|
copyPath.Click += (o, e) => {
|
||||||
|
Clipboard.SetText(repo.Path);
|
||||||
|
e.Handled = true;
|
||||||
|
};
|
||||||
|
|
||||||
var menu = new ContextMenu();
|
var menu = new ContextMenu();
|
||||||
menu.Items.Add(close);
|
|
||||||
menu.Items.Add(new Separator());
|
|
||||||
menu.Items.Add(copyPath);
|
|
||||||
menu.Items.Add(refresh);
|
menu.Items.Add(refresh);
|
||||||
|
menu.Items.Add(bookmark);
|
||||||
|
menu.Items.Add(copyPath);
|
||||||
menu.IsOpen = true;
|
menu.IsOpen = true;
|
||||||
|
|
||||||
ev.Handled = true;
|
ev.Handled = true;
|
||||||
|
@ -227,11 +274,14 @@ namespace SourceGit.UI {
|
||||||
|
|
||||||
#region DRAG_DROP
|
#region DRAG_DROP
|
||||||
private void TabsMouseMove(object sender, MouseEventArgs e) {
|
private void TabsMouseMove(object sender, MouseEventArgs e) {
|
||||||
var tab = e.Source as TabItem;
|
var item = e.Source as TabItem;
|
||||||
if (tab == null || (tab.DataContext as Tab).Repo == null) return;
|
if (item == null) return;
|
||||||
|
|
||||||
|
var tab = item.DataContext as Tab;
|
||||||
|
if (tab == null || tab.Repo == null) return;
|
||||||
|
|
||||||
if (Mouse.LeftButton == MouseButtonState.Pressed) {
|
if (Mouse.LeftButton == MouseButtonState.Pressed) {
|
||||||
DragDrop.DoDragDrop(tab, tab, DragDropEffects.All);
|
DragDrop.DoDragDrop(item, item, DragDropEffects.All);
|
||||||
e.Handled = true;
|
e.Handled = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue