mirror of
https://github.com/sourcegit-scm/sourcegit
synced 2025-05-23 21:24:59 +00:00
style: add .editorconfig for code formatting. see issu #25
This commit is contained in:
parent
a8eeea4f78
commit
18aaa0a143
225 changed files with 7781 additions and 3911 deletions
|
@ -1,12 +1,14 @@
|
|||
using Avalonia.Data.Converters;
|
||||
using Avalonia.Media;
|
||||
|
||||
namespace SourceGit.Converters {
|
||||
public static class BookmarkConverters {
|
||||
namespace SourceGit.Converters
|
||||
{
|
||||
public static class BookmarkConverters
|
||||
{
|
||||
public static FuncValueConverter<int, IBrush> ToBrush =
|
||||
new FuncValueConverter<int, IBrush>(bookmark => Models.Bookmarks.Brushes[bookmark]);
|
||||
|
||||
public static FuncValueConverter<int, double> ToStrokeThickness =
|
||||
new FuncValueConverter<int, double>(bookmark => bookmark == 0 ? 1.0 : 0);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,8 +1,10 @@
|
|||
using Avalonia.Data.Converters;
|
||||
|
||||
namespace SourceGit.Converters {
|
||||
public static class BoolConverters {
|
||||
namespace SourceGit.Converters
|
||||
{
|
||||
public static class BoolConverters
|
||||
{
|
||||
public static FuncValueConverter<bool, double> ToCommitOpacity =
|
||||
new FuncValueConverter<bool, double>(x => x ? 1 : 0.5);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,8 +1,10 @@
|
|||
using Avalonia.Data.Converters;
|
||||
|
||||
namespace SourceGit.Converters {
|
||||
public static class BranchConverters {
|
||||
namespace SourceGit.Converters
|
||||
{
|
||||
public static class BranchConverters
|
||||
{
|
||||
public static FuncValueConverter<Models.Branch, string> ToName =
|
||||
new FuncValueConverter<Models.Branch, string>(v => v.IsLocal ? v.Name : $"{v.Remote}/{v.Name}");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -2,17 +2,21 @@
|
|||
using Avalonia.Data.Converters;
|
||||
using Avalonia.Media;
|
||||
|
||||
namespace SourceGit.Converters {
|
||||
public static class ChangeViewModeConverters {
|
||||
namespace SourceGit.Converters
|
||||
{
|
||||
public static class ChangeViewModeConverters
|
||||
{
|
||||
public static 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;
|
||||
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;
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -25,4 +29,4 @@ namespace SourceGit.Converters {
|
|||
public static FuncValueConverter<Models.ChangeViewMode, bool> IsTree =
|
||||
new FuncValueConverter<Models.ChangeViewMode, bool>(v => v == Models.ChangeViewMode.Tree);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -3,32 +3,37 @@ using Avalonia.Controls;
|
|||
using Avalonia.Data.Converters;
|
||||
using Avalonia.Media;
|
||||
|
||||
namespace SourceGit.Converters {
|
||||
public static class DecoratorTypeConverters {
|
||||
namespace SourceGit.Converters
|
||||
{
|
||||
public static class DecoratorTypeConverters
|
||||
{
|
||||
public static FuncValueConverter<Models.DecoratorType, IBrush> ToBackground =
|
||||
new FuncValueConverter<Models.DecoratorType, IBrush>(v => {
|
||||
new FuncValueConverter<Models.DecoratorType, IBrush>(v =>
|
||||
{
|
||||
if (v == Models.DecoratorType.Tag) return Models.DecoratorResources.Backgrounds[0];
|
||||
return Models.DecoratorResources.Backgrounds[1];
|
||||
});
|
||||
|
||||
public static FuncValueConverter<Models.DecoratorType, StreamGeometry> ToIcon =
|
||||
new FuncValueConverter<Models.DecoratorType, StreamGeometry>(v => {
|
||||
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;
|
||||
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;
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,7 +1,9 @@
|
|||
using Avalonia.Data.Converters;
|
||||
|
||||
namespace SourceGit.Converters {
|
||||
public static class IntConverters {
|
||||
namespace SourceGit.Converters
|
||||
{
|
||||
public static class IntConverters
|
||||
{
|
||||
public static FuncValueConverter<int, bool> IsGreaterThanZero =
|
||||
new FuncValueConverter<int, bool>(v => v > 0);
|
||||
|
||||
|
@ -11,4 +13,4 @@ namespace SourceGit.Converters {
|
|||
public static FuncValueConverter<int, bool> IsOne =
|
||||
new FuncValueConverter<int, bool>(v => v == 1);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,11 +1,15 @@
|
|||
using Avalonia.Collections;
|
||||
using Avalonia.Data.Converters;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace SourceGit.Converters {
|
||||
public static class LauncherPageConverters {
|
||||
using Avalonia.Collections;
|
||||
using Avalonia.Data.Converters;
|
||||
|
||||
namespace SourceGit.Converters
|
||||
{
|
||||
public static class LauncherPageConverters
|
||||
{
|
||||
public static FuncMultiValueConverter<object, bool> ToTabSeperatorVisible =
|
||||
new FuncMultiValueConverter<object, bool>(v => {
|
||||
new FuncMultiValueConverter<object, bool>(v =>
|
||||
{
|
||||
if (v == null) return false;
|
||||
|
||||
var array = new List<object>();
|
||||
|
@ -18,11 +22,14 @@ namespace SourceGit.Converters {
|
|||
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))) {
|
||||
if (selected != null && collections != null && (self == selected || collections.IndexOf(self) + 1 == collections.IndexOf(selected)))
|
||||
{
|
||||
return false;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
return true;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,12 +1,15 @@
|
|||
using Avalonia.Data.Converters;
|
||||
using System.Collections;
|
||||
using System.Collections;
|
||||
|
||||
namespace SourceGit.Converters {
|
||||
public static class ListConverters {
|
||||
using Avalonia.Data.Converters;
|
||||
|
||||
namespace SourceGit.Converters
|
||||
{
|
||||
public static class ListConverters
|
||||
{
|
||||
public static FuncValueConverter<IList, string> ToCount =
|
||||
new FuncValueConverter<IList, string>(v => $" ({v.Count})");
|
||||
|
||||
public static FuncValueConverter<IList, bool> IsNotNullOrEmpty =
|
||||
new FuncValueConverter<IList, bool>(v => v != null && v.Count > 0);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,8 +1,11 @@
|
|||
using Avalonia.Data.Converters;
|
||||
using System.IO;
|
||||
using System.IO;
|
||||
|
||||
namespace SourceGit.Converters {
|
||||
public static class PathConverters {
|
||||
using Avalonia.Data.Converters;
|
||||
|
||||
namespace SourceGit.Converters
|
||||
{
|
||||
public static class PathConverters
|
||||
{
|
||||
public static FuncValueConverter<string, string> PureFileName =
|
||||
new FuncValueConverter<string, string>(fullpath => Path.GetFileName(fullpath) ?? "");
|
||||
|
||||
|
@ -10,9 +13,10 @@ namespace SourceGit.Converters {
|
|||
new FuncValueConverter<string, string>(fullpath => Path.GetDirectoryName(fullpath) ?? "");
|
||||
|
||||
public static FuncValueConverter<string, string> TruncateIfTooLong =
|
||||
new FuncValueConverter<string, string>(fullpath => {
|
||||
new FuncValueConverter<string, string>(fullpath =>
|
||||
{
|
||||
if (fullpath.Length <= 50) return fullpath;
|
||||
return fullpath.Substring(0, 20) + ".../" + Path.GetFileName(fullpath);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,35 +1,49 @@
|
|||
using Avalonia.Data.Converters;
|
||||
using Avalonia.Styling;
|
||||
using System;
|
||||
using System;
|
||||
using System.Globalization;
|
||||
|
||||
namespace SourceGit.Converters {
|
||||
public static class StringConverters {
|
||||
public class ToLocaleConverter : IValueConverter {
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) {
|
||||
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) {
|
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
return (value as Models.Locale).Key;
|
||||
}
|
||||
}
|
||||
|
||||
public static ToLocaleConverter ToLocale = new ToLocaleConverter();
|
||||
|
||||
public class ToThemeConverter : IValueConverter {
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) {
|
||||
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)) {
|
||||
if (theme.Equals("Light", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return ThemeVariant.Light;
|
||||
} else if (theme.Equals("Dark", StringComparison.OrdinalIgnoreCase)) {
|
||||
}
|
||||
else if (theme.Equals("Dark", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return ThemeVariant.Dark;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
return ThemeVariant.Default;
|
||||
}
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) {
|
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
var theme = (ThemeVariant)value;
|
||||
return theme.Key;
|
||||
}
|
||||
|
@ -37,13 +51,16 @@ namespace SourceGit.Converters {
|
|||
|
||||
public static ToThemeConverter ToTheme = new ToThemeConverter();
|
||||
|
||||
public class FormatByResourceKeyConverter : IValueConverter {
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) {
|
||||
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) {
|
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
|
@ -53,4 +70,4 @@ namespace SourceGit.Converters {
|
|||
public static FuncValueConverter<string, string> ToShortSHA =
|
||||
new FuncValueConverter<string, string>(v => v.Length > 10 ? v.Substring(0, 10) : v);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,38 +1,55 @@
|
|||
using Avalonia.Controls;
|
||||
using System;
|
||||
|
||||
using Avalonia;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Data.Converters;
|
||||
using Avalonia.Media;
|
||||
using Avalonia;
|
||||
using System;
|
||||
|
||||
namespace SourceGit.Converters {
|
||||
public static class WindowStateConverters {
|
||||
namespace SourceGit.Converters
|
||||
{
|
||||
public static class WindowStateConverters
|
||||
{
|
||||
public static FuncValueConverter<WindowState, Thickness> ToContentMargin =
|
||||
new FuncValueConverter<WindowState, Thickness>(state => {
|
||||
if (OperatingSystem.IsWindows() && state == WindowState.Maximized) {
|
||||
new FuncValueConverter<WindowState, Thickness>(state =>
|
||||
{
|
||||
if (OperatingSystem.IsWindows() && state == WindowState.Maximized)
|
||||
{
|
||||
return new Thickness(6);
|
||||
} else if (OperatingSystem.IsLinux() && state != WindowState.Maximized) {
|
||||
}
|
||||
else if (OperatingSystem.IsLinux() && state != WindowState.Maximized)
|
||||
{
|
||||
return new Thickness(6);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
return new Thickness(0);
|
||||
}
|
||||
});
|
||||
|
||||
public static FuncValueConverter<WindowState, GridLength> ToTitleBarHeight =
|
||||
new FuncValueConverter<WindowState, GridLength>(state => {
|
||||
if (state == WindowState.Maximized) {
|
||||
new FuncValueConverter<WindowState, GridLength>(state =>
|
||||
{
|
||||
if (state == WindowState.Maximized)
|
||||
{
|
||||
return new GridLength(30);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
return new GridLength(38);
|
||||
}
|
||||
});
|
||||
|
||||
public static FuncValueConverter<WindowState, StreamGeometry> ToMaxOrRestoreIcon =
|
||||
new FuncValueConverter<WindowState, StreamGeometry>(state => {
|
||||
if (state == WindowState.Maximized) {
|
||||
new FuncValueConverter<WindowState, StreamGeometry>(state =>
|
||||
{
|
||||
if (state == WindowState.Maximized)
|
||||
{
|
||||
return Application.Current?.FindResource("Icons.Window.Restore") as StreamGeometry;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
return Application.Current?.FindResource("Icons.Window.Maximize") as StreamGeometry;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue