mirror of
https://github.com/sourcegit-scm/sourcegit
synced 2025-05-22 04:34: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,103 +1,138 @@
|
|||
using Avalonia.Collections;
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using System;
|
||||
using System;
|
||||
|
||||
namespace SourceGit.ViewModels {
|
||||
public class Welcome : ObservableObject {
|
||||
public bool IsClearSearchVisible {
|
||||
using Avalonia.Collections;
|
||||
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
|
||||
namespace SourceGit.ViewModels
|
||||
{
|
||||
public class Welcome : ObservableObject
|
||||
{
|
||||
public bool IsClearSearchVisible
|
||||
{
|
||||
get => !string.IsNullOrEmpty(_searchFilter);
|
||||
}
|
||||
|
||||
public AvaloniaList<RepositoryNode> RepositoryNodes {
|
||||
public AvaloniaList<RepositoryNode> RepositoryNodes
|
||||
{
|
||||
get => Preference.Instance.RepositoryNodes;
|
||||
}
|
||||
|
||||
public string SearchFilter {
|
||||
public string SearchFilter
|
||||
{
|
||||
get => _searchFilter;
|
||||
set {
|
||||
if (SetProperty(ref _searchFilter, value)) {
|
||||
set
|
||||
{
|
||||
if (SetProperty(ref _searchFilter, value))
|
||||
{
|
||||
Referesh();
|
||||
OnPropertyChanged(nameof(IsClearSearchVisible));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void InitRepository(string path) {
|
||||
if (!Preference.Instance.IsGitConfigured) {
|
||||
public void InitRepository(string path)
|
||||
{
|
||||
if (!Preference.Instance.IsGitConfigured)
|
||||
{
|
||||
App.RaiseException(PopupHost.Active.GetId(), App.Text("NotConfigured"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (PopupHost.CanCreatePopup()) {
|
||||
if (PopupHost.CanCreatePopup())
|
||||
{
|
||||
PopupHost.ShowPopup(new Init(path));
|
||||
}
|
||||
}
|
||||
|
||||
public void Clone(object param) {
|
||||
public void Clone(object param)
|
||||
{
|
||||
var launcher = param as Launcher;
|
||||
var page = launcher.ActivePage;
|
||||
|
||||
if (!Preference.Instance.IsGitConfigured) {
|
||||
if (!Preference.Instance.IsGitConfigured)
|
||||
{
|
||||
App.RaiseException(page.GetId(), App.Text("NotConfigured"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (PopupHost.CanCreatePopup()) {
|
||||
if (PopupHost.CanCreatePopup())
|
||||
{
|
||||
PopupHost.ShowPopup(new Clone(launcher, page));
|
||||
}
|
||||
}
|
||||
|
||||
public void OpenTerminal() {
|
||||
if (!Preference.Instance.IsGitConfigured) {
|
||||
public void OpenTerminal()
|
||||
{
|
||||
if (!Preference.Instance.IsGitConfigured)
|
||||
{
|
||||
App.RaiseException(PopupHost.Active.GetId(), App.Text("NotConfigured"));
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
Native.OS.OpenTerminal(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void ClearSearchFilter() {
|
||||
public void ClearSearchFilter()
|
||||
{
|
||||
SearchFilter = string.Empty;
|
||||
}
|
||||
|
||||
public void AddFolder() {
|
||||
public void AddFolder()
|
||||
{
|
||||
if (PopupHost.CanCreatePopup()) PopupHost.ShowPopup(new CreateGroup(null));
|
||||
}
|
||||
|
||||
public void MoveNode(RepositoryNode from, RepositoryNode to) {
|
||||
public void MoveNode(RepositoryNode from, RepositoryNode to)
|
||||
{
|
||||
Preference.MoveNode(from, to);
|
||||
}
|
||||
|
||||
private void Referesh() {
|
||||
if (string.IsNullOrWhiteSpace(_searchFilter)) {
|
||||
private void Referesh()
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(_searchFilter))
|
||||
{
|
||||
foreach (var node in RepositoryNodes) ResetVisibility(node);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (var node in RepositoryNodes) SetVisibilityBySearch(node);
|
||||
}
|
||||
}
|
||||
|
||||
private void ResetVisibility(RepositoryNode node) {
|
||||
private void ResetVisibility(RepositoryNode node)
|
||||
{
|
||||
node.IsVisible = true;
|
||||
foreach (var subNode in node.SubNodes) ResetVisibility(subNode);
|
||||
}
|
||||
|
||||
private void SetVisibilityBySearch(RepositoryNode node) {
|
||||
if (!node.IsRepository) {
|
||||
if (node.Name.Contains(_searchFilter, StringComparison.OrdinalIgnoreCase)) {
|
||||
private void SetVisibilityBySearch(RepositoryNode node)
|
||||
{
|
||||
if (!node.IsRepository)
|
||||
{
|
||||
if (node.Name.Contains(_searchFilter, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
node.IsVisible = true;
|
||||
foreach (var subNode in node.SubNodes) ResetVisibility(subNode);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
bool hasVisibleSubNode = false;
|
||||
foreach (var subNode in node.SubNodes) {
|
||||
foreach (var subNode in node.SubNodes)
|
||||
{
|
||||
SetVisibilityBySearch(subNode);
|
||||
hasVisibleSubNode |= subNode.IsVisible;
|
||||
}
|
||||
node.IsVisible = hasVisibleSubNode;
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
node.IsVisible = node.Name.Contains(_searchFilter, StringComparison.OrdinalIgnoreCase);
|
||||
}
|
||||
}
|
||||
|
||||
private string _searchFilter = string.Empty;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue