mirror of
https://github.com/sourcegit-scm/sourcegit
synced 2025-05-23 21:24:59 +00:00
project: reorganize the structure of the project.
* remove dotnet-tool.json because the project does not rely on any dotnet tools. * remove Directory.Build.props because the solution has only one project. * move src/SourceGit to src. It's not needed to put all sources into a subfolder of src since there's only one project.
This commit is contained in:
parent
96e60da7ad
commit
96d4150d26
319 changed files with 37 additions and 53 deletions
14
src/Converters/BookmarkConverters.cs
Normal file
14
src/Converters/BookmarkConverters.cs
Normal file
|
@ -0,0 +1,14 @@
|
|||
using Avalonia.Data.Converters;
|
||||
using Avalonia.Media;
|
||||
|
||||
namespace SourceGit.Converters
|
||||
{
|
||||
public static class BookmarkConverters
|
||||
{
|
||||
public static readonly FuncValueConverter<int, IBrush> ToBrush =
|
||||
new FuncValueConverter<int, IBrush>(bookmark => Models.Bookmarks.Brushes[bookmark]);
|
||||
|
||||
public static readonly FuncValueConverter<int, double> ToStrokeThickness =
|
||||
new FuncValueConverter<int, double>(bookmark => bookmark == 0 ? 1.0 : 0);
|
||||
}
|
||||
}
|
14
src/Converters/BoolConverters.cs
Normal file
14
src/Converters/BoolConverters.cs
Normal file
|
@ -0,0 +1,14 @@
|
|||
using Avalonia.Data.Converters;
|
||||
using Avalonia.Media;
|
||||
|
||||
namespace SourceGit.Converters
|
||||
{
|
||||
public static class BoolConverters
|
||||
{
|
||||
public static readonly FuncValueConverter<bool, double> ToCommitOpacity =
|
||||
new FuncValueConverter<bool, double>(x => x ? 1 : 0.5);
|
||||
|
||||
public static readonly FuncValueConverter<bool, FontWeight> ToCommitFontWeight =
|
||||
new FuncValueConverter<bool, FontWeight>(x => x ? FontWeight.Bold : FontWeight.Regular);
|
||||
}
|
||||
}
|
10
src/Converters/BranchConverters.cs
Normal file
10
src/Converters/BranchConverters.cs
Normal file
|
@ -0,0 +1,10 @@
|
|||
using Avalonia.Data.Converters;
|
||||
|
||||
namespace SourceGit.Converters
|
||||
{
|
||||
public static class BranchConverters
|
||||
{
|
||||
public static readonly FuncValueConverter<Models.Branch, string> ToName =
|
||||
new FuncValueConverter<Models.Branch, string>(v => v.IsLocal ? v.Name : $"{v.Remote}/{v.Name}");
|
||||
}
|
||||
}
|
32
src/Converters/ChangeViewModeConverters.cs
Normal file
32
src/Converters/ChangeViewModeConverters.cs
Normal file
|
@ -0,0 +1,32 @@
|
|||
using Avalonia.Controls;
|
||||
using Avalonia.Data.Converters;
|
||||
using Avalonia.Media;
|
||||
|
||||
namespace SourceGit.Converters
|
||||
{
|
||||
public static class ChangeViewModeConverters
|
||||
{
|
||||
public static readonly FuncValueConverter<Models.ChangeViewMode, StreamGeometry> ToIcon =
|
||||
new FuncValueConverter<Models.ChangeViewMode, StreamGeometry>(v =>
|
||||
{
|
||||
switch (v)
|
||||
{
|
||||
case Models.ChangeViewMode.List:
|
||||
return App.Current?.FindResource("Icons.List") as StreamGeometry;
|
||||
case Models.ChangeViewMode.Grid:
|
||||
return App.Current?.FindResource("Icons.Grid") as StreamGeometry;
|
||||
default:
|
||||
return App.Current?.FindResource("Icons.Tree") as StreamGeometry;
|
||||
}
|
||||
});
|
||||
|
||||
public static readonly FuncValueConverter<Models.ChangeViewMode, bool> IsList =
|
||||
new FuncValueConverter<Models.ChangeViewMode, bool>(v => v == Models.ChangeViewMode.List);
|
||||
|
||||
public static readonly FuncValueConverter<Models.ChangeViewMode, bool> IsGrid =
|
||||
new FuncValueConverter<Models.ChangeViewMode, bool>(v => v == Models.ChangeViewMode.Grid);
|
||||
|
||||
public static readonly FuncValueConverter<Models.ChangeViewMode, bool> IsTree =
|
||||
new FuncValueConverter<Models.ChangeViewMode, bool>(v => v == Models.ChangeViewMode.Tree);
|
||||
}
|
||||
}
|
40
src/Converters/DecoratorTypeConverters.cs
Normal file
40
src/Converters/DecoratorTypeConverters.cs
Normal file
|
@ -0,0 +1,40 @@
|
|||
using Avalonia;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Data.Converters;
|
||||
using Avalonia.Media;
|
||||
|
||||
namespace SourceGit.Converters
|
||||
{
|
||||
public static class DecoratorTypeConverters
|
||||
{
|
||||
public static readonly FuncValueConverter<Models.DecoratorType, IBrush> ToBackground =
|
||||
new FuncValueConverter<Models.DecoratorType, IBrush>(v =>
|
||||
{
|
||||
if (v == Models.DecoratorType.Tag)
|
||||
return Models.DecoratorResources.Backgrounds[0];
|
||||
return Models.DecoratorResources.Backgrounds[1];
|
||||
});
|
||||
|
||||
public static readonly FuncValueConverter<Models.DecoratorType, StreamGeometry> ToIcon =
|
||||
new FuncValueConverter<Models.DecoratorType, StreamGeometry>(v =>
|
||||
{
|
||||
var key = "Icons.Tag";
|
||||
switch (v)
|
||||
{
|
||||
case Models.DecoratorType.CurrentBranchHead:
|
||||
key = "Icons.Check";
|
||||
break;
|
||||
case Models.DecoratorType.RemoteBranchHead:
|
||||
key = "Icons.Remote";
|
||||
break;
|
||||
case Models.DecoratorType.LocalBranchHead:
|
||||
key = "Icons.Branch";
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return Application.Current?.FindResource(key) as StreamGeometry;
|
||||
});
|
||||
}
|
||||
}
|
13
src/Converters/FontSizeModifyConverters.cs
Normal file
13
src/Converters/FontSizeModifyConverters.cs
Normal file
|
@ -0,0 +1,13 @@
|
|||
using Avalonia.Data.Converters;
|
||||
|
||||
namespace SourceGit.Converters
|
||||
{
|
||||
public static class FontSizeModifyConverters
|
||||
{
|
||||
public static readonly FuncValueConverter<double, double> Increase =
|
||||
new FuncValueConverter<double, double>(v => v + 1.0);
|
||||
|
||||
public static readonly FuncValueConverter<double, double> Decrease =
|
||||
new FuncValueConverter<double, double>(v => v - 1.0);
|
||||
}
|
||||
}
|
19
src/Converters/IntConverters.cs
Normal file
19
src/Converters/IntConverters.cs
Normal file
|
@ -0,0 +1,19 @@
|
|||
using Avalonia.Data.Converters;
|
||||
|
||||
namespace SourceGit.Converters
|
||||
{
|
||||
public static class IntConverters
|
||||
{
|
||||
public static readonly FuncValueConverter<int, bool> IsGreaterThanZero =
|
||||
new FuncValueConverter<int, bool>(v => v > 0);
|
||||
|
||||
public static readonly FuncValueConverter<int, bool> IsZero =
|
||||
new FuncValueConverter<int, bool>(v => v == 0);
|
||||
|
||||
public static readonly FuncValueConverter<int, bool> IsOne =
|
||||
new FuncValueConverter<int, bool>(v => v == 1);
|
||||
|
||||
public static readonly FuncValueConverter<int, bool> IsNotOne =
|
||||
new FuncValueConverter<int, bool>(v => v != 1);
|
||||
}
|
||||
}
|
38
src/Converters/LauncherPageConverters.cs
Normal file
38
src/Converters/LauncherPageConverters.cs
Normal file
|
@ -0,0 +1,38 @@
|
|||
using System.Collections.Generic;
|
||||
|
||||
using Avalonia.Collections;
|
||||
using Avalonia.Data.Converters;
|
||||
|
||||
namespace SourceGit.Converters
|
||||
{
|
||||
public static class LauncherPageConverters
|
||||
{
|
||||
public static readonly FuncMultiValueConverter<object, bool> ToTabSeperatorVisible =
|
||||
new FuncMultiValueConverter<object, bool>(v =>
|
||||
{
|
||||
if (v == null)
|
||||
return false;
|
||||
|
||||
var array = new List<object>();
|
||||
array.AddRange(v);
|
||||
if (array.Count != 3)
|
||||
return false;
|
||||
|
||||
var self = array[0] as ViewModels.LauncherPage;
|
||||
if (self == null)
|
||||
return false;
|
||||
|
||||
var selected = array[1] as ViewModels.LauncherPage;
|
||||
var collections = array[2] as AvaloniaList<ViewModels.LauncherPage>;
|
||||
|
||||
if (selected != null && collections != null && (self == selected || collections.IndexOf(self) + 1 == collections.IndexOf(selected)))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
return true;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
15
src/Converters/ListConverters.cs
Normal file
15
src/Converters/ListConverters.cs
Normal file
|
@ -0,0 +1,15 @@
|
|||
using System.Collections;
|
||||
|
||||
using Avalonia.Data.Converters;
|
||||
|
||||
namespace SourceGit.Converters
|
||||
{
|
||||
public static class ListConverters
|
||||
{
|
||||
public static readonly FuncValueConverter<IList, string> ToCount =
|
||||
new FuncValueConverter<IList, string>(v => $" ({v.Count})");
|
||||
|
||||
public static readonly FuncValueConverter<IList, bool> IsNotNullOrEmpty =
|
||||
new FuncValueConverter<IList, bool>(v => v != null && v.Count > 0);
|
||||
}
|
||||
}
|
23
src/Converters/PathConverters.cs
Normal file
23
src/Converters/PathConverters.cs
Normal file
|
@ -0,0 +1,23 @@
|
|||
using System.IO;
|
||||
|
||||
using Avalonia.Data.Converters;
|
||||
|
||||
namespace SourceGit.Converters
|
||||
{
|
||||
public static class PathConverters
|
||||
{
|
||||
public static readonly FuncValueConverter<string, string> PureFileName =
|
||||
new FuncValueConverter<string, string>(fullpath => Path.GetFileName(fullpath) ?? "");
|
||||
|
||||
public static readonly FuncValueConverter<string, string> PureDirectoryName =
|
||||
new FuncValueConverter<string, string>(fullpath => Path.GetDirectoryName(fullpath) ?? "");
|
||||
|
||||
public static readonly FuncValueConverter<string, string> TruncateIfTooLong =
|
||||
new FuncValueConverter<string, string>(fullpath =>
|
||||
{
|
||||
if (fullpath.Length <= 50)
|
||||
return fullpath;
|
||||
return fullpath.Substring(0, 20) + ".../" + Path.GetFileName(fullpath);
|
||||
});
|
||||
}
|
||||
}
|
73
src/Converters/StringConverters.cs
Normal file
73
src/Converters/StringConverters.cs
Normal file
|
@ -0,0 +1,73 @@
|
|||
using System;
|
||||
using System.Globalization;
|
||||
|
||||
using Avalonia.Data.Converters;
|
||||
using Avalonia.Styling;
|
||||
|
||||
namespace SourceGit.Converters
|
||||
{
|
||||
public static class StringConverters
|
||||
{
|
||||
public class ToLocaleConverter : IValueConverter
|
||||
{
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
return Models.Locale.Supported.Find(x => x.Key == value as string);
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
return (value as Models.Locale).Key;
|
||||
}
|
||||
}
|
||||
|
||||
public static readonly ToLocaleConverter ToLocale = new ToLocaleConverter();
|
||||
|
||||
public class ToThemeConverter : IValueConverter
|
||||
{
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
var theme = (string)value;
|
||||
if (theme.Equals("Light", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return ThemeVariant.Light;
|
||||
}
|
||||
else if (theme.Equals("Dark", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return ThemeVariant.Dark;
|
||||
}
|
||||
else
|
||||
{
|
||||
return ThemeVariant.Default;
|
||||
}
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
var theme = (ThemeVariant)value;
|
||||
return theme.Key;
|
||||
}
|
||||
}
|
||||
|
||||
public static readonly ToThemeConverter ToTheme = new ToThemeConverter();
|
||||
|
||||
public class FormatByResourceKeyConverter : IValueConverter
|
||||
{
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
var key = parameter as string;
|
||||
return App.Text(key, value);
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
|
||||
public static readonly FormatByResourceKeyConverter FormatByResourceKey = new FormatByResourceKeyConverter();
|
||||
|
||||
public static readonly FuncValueConverter<string, string> ToShortSHA =
|
||||
new FuncValueConverter<string, string>(v => v.Length > 10 ? v.Substring(0, 10) : v);
|
||||
}
|
||||
}
|
58
src/Converters/WindowStateConverters.cs
Normal file
58
src/Converters/WindowStateConverters.cs
Normal file
|
@ -0,0 +1,58 @@
|
|||
using System;
|
||||
|
||||
using Avalonia;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Data.Converters;
|
||||
using Avalonia.Media;
|
||||
|
||||
namespace SourceGit.Converters
|
||||
{
|
||||
public static class WindowStateConverters
|
||||
{
|
||||
public static readonly FuncValueConverter<WindowState, Thickness> ToContentMargin =
|
||||
new FuncValueConverter<WindowState, Thickness>(state =>
|
||||
{
|
||||
if (OperatingSystem.IsWindows() && state == WindowState.Maximized)
|
||||
{
|
||||
return new Thickness(6);
|
||||
}
|
||||
else if (OperatingSystem.IsLinux() && state != WindowState.Maximized)
|
||||
{
|
||||
return new Thickness(6);
|
||||
}
|
||||
else
|
||||
{
|
||||
return new Thickness(0);
|
||||
}
|
||||
});
|
||||
|
||||
public static readonly FuncValueConverter<WindowState, GridLength> ToTitleBarHeight =
|
||||
new FuncValueConverter<WindowState, GridLength>(state =>
|
||||
{
|
||||
if (state == WindowState.Maximized)
|
||||
{
|
||||
return new GridLength(30);
|
||||
}
|
||||
else
|
||||
{
|
||||
return new GridLength(38);
|
||||
}
|
||||
});
|
||||
|
||||
public static readonly FuncValueConverter<WindowState, StreamGeometry> ToMaxOrRestoreIcon =
|
||||
new FuncValueConverter<WindowState, StreamGeometry>(state =>
|
||||
{
|
||||
if (state == WindowState.Maximized)
|
||||
{
|
||||
return Application.Current?.FindResource("Icons.Window.Restore") as StreamGeometry;
|
||||
}
|
||||
else
|
||||
{
|
||||
return Application.Current?.FindResource("Icons.Window.Maximize") as StreamGeometry;
|
||||
}
|
||||
});
|
||||
|
||||
public static readonly FuncValueConverter<WindowState, bool> IsNormal =
|
||||
new FuncValueConverter<WindowState, bool>(state => state == WindowState.Normal);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue