Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion SalmonEgg/SalmonEgg/App.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
using System;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.UI.Xaml.Controls;
using SalmonEgg.Infrastructure.Storage;
using SalmonEgg.Presentation.Models;
using SalmonEgg.Presentation.Services;
using SalmonEgg.Infrastructure.Storage;

namespace SalmonEgg;

Expand Down
4 changes: 2 additions & 2 deletions SalmonEgg/SalmonEgg/Controls/ChatInputArea.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@
using Microsoft.UI.Xaml.Input;
using Microsoft.UI.Xaml.Media;
using SalmonEgg.Presentation.Core.Services.Input;
using SalmonEgg.Presentation.Core.ViewModels.Composer;
using SalmonEgg.Presentation.Core.ViewModels.Chat.Selectors;
using SalmonEgg.Presentation.Core.ViewModels.Composer;
using SalmonEgg.Presentation.ViewModels.Chat;
using XamlFocusManager = Microsoft.UI.Xaml.Input.FocusManager;
using WindowActivatedEventArgs = Microsoft.UI.Xaml.WindowActivatedEventArgs;
using XamlFocusManager = Microsoft.UI.Xaml.Input.FocusManager;

namespace SalmonEgg.Controls;

Expand Down
11 changes: 5 additions & 6 deletions SalmonEgg/SalmonEgg/Controls/ChatSkeleton.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
using Microsoft.UI.Xaml.Controls;

namespace SalmonEgg.Controls
namespace SalmonEgg.Controls;

public sealed partial class ChatSkeleton : UserControl
{
public sealed partial class ChatSkeleton : UserControl
public ChatSkeleton()
{
public ChatSkeleton()
{
InitializeComponent();
}
InitializeComponent();
}
}
2 changes: 1 addition & 1 deletion SalmonEgg/SalmonEgg/Controls/ResizeGrip.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Input;
using Microsoft.UI.Xaml.Controls;
using Microsoft.UI.Xaml.Input;

namespace SalmonEgg.Controls;

Expand Down
2 changes: 1 addition & 1 deletion SalmonEgg/SalmonEgg/Controls/SettingsBreadcrumbBar.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
using System.Collections.Generic;
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
using SalmonEgg.Presentation.Models.Navigation;
using SalmonEgg.Presentation.Core.Services;
using SalmonEgg.Presentation.Models.Navigation;

namespace SalmonEgg.Controls;

Expand Down
4 changes: 2 additions & 2 deletions SalmonEgg/SalmonEgg/Controls/ShortcutRecorder.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
using System;
using System.Globalization;
using System.ComponentModel;
using System.Globalization;
using System.Runtime.CompilerServices;
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
using Microsoft.UI.Xaml.Input;
using Windows.System;
using SalmonEgg.Presentation.Core.Services.Shortcuts;
using Windows.System;

namespace SalmonEgg.Controls;

Expand Down
28 changes: 14 additions & 14 deletions SalmonEgg/SalmonEgg/Platforms/Desktop/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,21 @@ internal class Program
{
[STAThread]
static void Main(string[] args)
{
App.InitializeLogging();
{
App.InitializeLogging();

var host = UnoPlatformHostBuilder.Create()
.App(() => new App())
.UseX11()
.UseLinuxFrameBuffer()
.UseMacOS()
.UseWin32()
.Build();
var host = UnoPlatformHostBuilder.Create()
.App(() => new App())
.UseX11()
.UseLinuxFrameBuffer()
.UseMacOS()
.UseWin32()
.Build();

// Some hosting configurations may reset the ambient logger factory during Build().
// Re-apply our filters before running to suppress known noisy categories (e.g., RevealBrush setters on Skia).
App.InitializeLogging();
// Some hosting configurations may reset the ambient logger factory during Build().
// Re-apply our filters before running to suppress known noisy categories (e.g., RevealBrush setters on Skia).
App.InitializeLogging();

host.RunAsync().GetAwaiter().GetResult();
}
host.RunAsync().GetAwaiter().GetResult();
}
}
2 changes: 1 addition & 1 deletion SalmonEgg/SalmonEgg/Platforms/WebAssembly/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ public static async Task Main(string[] args)

await host.RunAsync();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,41 +2,40 @@
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Data;

namespace SalmonEgg.Presentation.Converters
namespace SalmonEgg.Presentation.Converters;

/// <summary>
/// 将布尔值转换为 Visibility
/// Requirements: 4.2
/// </summary>
public class BoolToVisibilityConverter : IValueConverter
{
/// <summary>
/// 将布尔值转换为 Visibility
/// Requirements: 4.2
/// </summary>
public class BoolToVisibilityConverter : IValueConverter
public object Convert(object value, Type targetType, object parameter, string language)
{
public object Convert(object value, Type targetType, object parameter, string language)
if (value is bool boolValue)
{
if (value is bool boolValue)
{
bool invert = parameter?.ToString() == "Invert";
if (invert) boolValue = !boolValue;
return boolValue ? Visibility.Visible : Visibility.Collapsed;
}

if (value is string stringValue)
{
return string.IsNullOrWhiteSpace(stringValue) ? Visibility.Collapsed : Visibility.Visible;
}

return Visibility.Collapsed;
bool invert = parameter?.ToString() == "Invert";
if (invert) boolValue = !boolValue;
return boolValue ? Visibility.Visible : Visibility.Collapsed;
}

public object ConvertBack(object value, Type targetType, object parameter, string language)
if (value is string stringValue)
{
if (value is Visibility visibility)
{
var result = visibility == Visibility.Visible;
var invert = parameter?.ToString() == "Invert";
return invert ? !result : result;
}
return string.IsNullOrWhiteSpace(stringValue) ? Visibility.Collapsed : Visibility.Visible;
}

return false;
return Visibility.Collapsed;
}

public object ConvertBack(object value, Type targetType, object parameter, string language)
{
if (value is Visibility visibility)
{
var result = visibility == Visibility.Visible;
var invert = parameter?.ToString() == "Invert";
return invert ? !result : result;
}

return false;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,34 +2,33 @@
using Microsoft.UI.Xaml.Data;
using SalmonEgg.Domain.Models;

namespace SalmonEgg.Presentation.Converters
namespace SalmonEgg.Presentation.Converters;

/// <summary>
/// 将连接状态转换为颜色
/// Requirements: 4.2
/// </summary>
public class ConnectionStatusToColorConverter : IValueConverter
{
/// <summary>
/// 将连接状态转换为颜色
/// Requirements: 4.2
/// </summary>
public class ConnectionStatusToColorConverter : IValueConverter
public object Convert(object value, Type targetType, object parameter, string language)
{
public object Convert(object value, Type targetType, object parameter, string language)
if (value is ConnectionStatus status)
{
if (value is ConnectionStatus status)
return status switch
{
return status switch
{
ConnectionStatus.Connected => ThemeBrushConverter.Resolve("SystemFillColorSuccessBrush"),
ConnectionStatus.Connecting => ThemeBrushConverter.Resolve("AccentBrush"),
ConnectionStatus.Reconnecting => ThemeBrushConverter.Resolve("SystemFillColorCautionBrush", "AccentBrush"),
ConnectionStatus.Error => ThemeBrushConverter.Resolve("SystemFillColorCriticalBrush"),
_ => ThemeBrushConverter.Resolve("TextFillColorSecondaryBrush")
};
}

return ThemeBrushConverter.Resolve("TextFillColorSecondaryBrush");
ConnectionStatus.Connected => ThemeBrushConverter.Resolve("SystemFillColorSuccessBrush"),
ConnectionStatus.Connecting => ThemeBrushConverter.Resolve("AccentBrush"),
ConnectionStatus.Reconnecting => ThemeBrushConverter.Resolve("SystemFillColorCautionBrush", "AccentBrush"),
ConnectionStatus.Error => ThemeBrushConverter.Resolve("SystemFillColorCriticalBrush"),
_ => ThemeBrushConverter.Resolve("TextFillColorSecondaryBrush")
};
}

public object ConvertBack(object value, Type targetType, object parameter, string language)
{
throw new NotImplementedException();
}
return ThemeBrushConverter.Resolve("TextFillColorSecondaryBrush");
}

public object ConvertBack(object value, Type targetType, object parameter, string language)
{
throw new NotImplementedException();
}
}
33 changes: 16 additions & 17 deletions SalmonEgg/SalmonEgg/Presentation/Converters/InverseBoolConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,28 @@
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Data;

namespace SalmonEgg.Presentation.Converters
namespace SalmonEgg.Presentation.Converters;

/// <summary>
/// 将布尔值取反后转换为 Visibility
/// </summary>
public class InverseBoolConverter : IValueConverter
{
/// <summary>
/// 将布尔值取反后转换为 Visibility
/// </summary>
public class InverseBoolConverter : IValueConverter
public object Convert(object value, Type targetType, object parameter, string language)
{
public object Convert(object value, Type targetType, object parameter, string language)
if (value is bool boolValue)
{
if (value is bool boolValue)
{
return boolValue ? Visibility.Collapsed : Visibility.Visible;
}
return Visibility.Visible;
return boolValue ? Visibility.Collapsed : Visibility.Visible;
}
return Visibility.Visible;
}

public object ConvertBack(object value, Type targetType, object parameter, string language)
public object ConvertBack(object value, Type targetType, object parameter, string language)
{
if (value is Visibility visibility)
{
if (value is Visibility visibility)
{
return visibility == Visibility.Collapsed;
}
return true;
return visibility == Visibility.Collapsed;
}
return true;
}
}
Original file line number Diff line number Diff line change
@@ -1,30 +1,29 @@
using System;
using Microsoft.UI.Xaml.Data;

namespace SalmonEgg.Presentation.Converters
namespace SalmonEgg.Presentation.Converters;

/// <summary>
/// 将布尔值取反(返回 bool,不是 Visibility)
/// 用于 IsEnabled 等需要 bool 的属性
/// </summary>
public class InverseBooleanConverter : IValueConverter
{
/// <summary>
/// 将布尔值取反(返回 bool,不是 Visibility)
/// 用于 IsEnabled 等需要 bool 的属性
/// </summary>
public class InverseBooleanConverter : IValueConverter
public object Convert(object value, Type targetType, object parameter, string language)
{
public object Convert(object value, Type targetType, object parameter, string language)
if (value is bool boolValue)
{
if (value is bool boolValue)
{
return !boolValue;
}
return true;
return !boolValue;
}
return true;
}

public object ConvertBack(object value, Type targetType, object parameter, string language)
public object ConvertBack(object value, Type targetType, object parameter, string language)
{
if (value is bool boolValue)
{
if (value is bool boolValue)
{
return !boolValue;
}
return false;
return !boolValue;
}
return false;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,25 @@
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Data;

namespace SalmonEgg.Presentation.Converters
namespace SalmonEgg.Presentation.Converters;

/// <summary>
/// 将消息方向转换为对齐方式
/// Requirements: 4.2
/// </summary>
public class MessageDirectionToAlignmentConverter : IValueConverter
{
/// <summary>
/// 将消息方向转换为对齐方式
/// Requirements: 4.2
/// </summary>
public class MessageDirectionToAlignmentConverter : IValueConverter
public object Convert(object value, Type targetType, object parameter, string language)
{
public object Convert(object value, Type targetType, object parameter, string language)
if (value is bool isOutgoing)
{
if (value is bool isOutgoing)
{
return isOutgoing ? HorizontalAlignment.Right : HorizontalAlignment.Left;
}
return HorizontalAlignment.Left;
return isOutgoing ? HorizontalAlignment.Right : HorizontalAlignment.Left;
}
return HorizontalAlignment.Left;
}

public object ConvertBack(object value, Type targetType, object parameter, string language)
{
throw new NotImplementedException();
}
public object ConvertBack(object value, Type targetType, object parameter, string language)
{
throw new NotImplementedException();
}
}
Loading
Loading