- fix: DesignMode think

This commit is contained in:
2025-01-22 21:06:05 +03:00
parent 3af99d40a1
commit 019dd13d8e
11 changed files with 51 additions and 36 deletions

View File

@@ -1,4 +1,5 @@
<ResourceDictionary xmlns="https://github.com/avaloniaui" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<SolidColorBrush x:Key="NoneBackground">#00000000</SolidColorBrush>
<SolidColorBrush x:Key="DefaultBackground">#121212</SolidColorBrush>
<SolidColorBrush x:Key="DefaultForeground">#222222</SolidColorBrush>
<SolidColorBrush x:Key="DefaultSelected">#D95F59</SolidColorBrush>
</ResourceDictionary>

View File

@@ -1,12 +1,9 @@
<Styles xmlns="https://github.com/avaloniaui" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Style Selector="Window">
<Setter Property="Background" Value="#121212" />
<Setter Property="Background" Value="{StaticResource DefaultBackground}"/>
</Style>
<Style Selector="Border">
<Setter Property="BorderBrush" Value="#343334" />
<Setter Property="Background" Value="Transparent" />
<Setter Property="BorderThickness" Value="0" />
<Setter Property="BoxShadow" Value="0 0 2 2 #222222" />
<Setter Property="CornerRadius" Value="10" />
</Style>
<Style Selector="Label">
<Setter Property="Foreground" Value="#f7f7ff" />
@@ -30,7 +27,7 @@
<Style Selector="Button:pointerover">
<Setter Property="RenderTransform" Value="{x:Null}" />
<Setter Property="BorderThickness" Value="0,0,0,2" />
<Setter Property="BorderThickness" Value="0,0,0,0" />
</Style>
<Style Selector="Button.ViewSelectButton">
@@ -47,9 +44,11 @@
<Style Selector="TextBox">
<Setter Property="Foreground" Value="#f7f7ff" />
<Setter Property="SelectionForegroundBrush" Value="#f7f7ff" />
<Setter Property="BorderThickness" Value="0,0,0,1" />
<Setter Property="BorderThickness" Value="0,0,0,0" />
<Setter Property="BorderBrush" Value="#f7f7ff" />
<Setter Property="Background" Value="Transparent" />
</Style>
<Style Selector="TextBox"></Style>
<Style Selector="ListBoxItem">
<Setter Property="CornerRadius" Value="0,8,8,0" />
@@ -58,12 +57,11 @@
<Setter Property="Background" Value="Transparent" />
</Style>
<Style Selector="ListBox.AccountSelector &gt; ListBoxItem">
<Setter Property="CornerRadius" Value="0" />
<Setter Property="Margin" Value="0,0,0,0" />
<Setter Property="Padding" Value="0" />
<Setter Property="Background" Value="Transparent" />
<Setter Property="Focusable" Value="False" />
<Style Selector="ListBoxItem:selected">
<Setter Property="Background" Value="{StaticResource DefaultSelected}"/>
</Style>
<Style Selector="ListBoxItem:pressed">
<Setter Property="Background" Value="{StaticResource DefaultSelected}"/>
</Style>
<Style Selector="TextBox">

View File

@@ -44,7 +44,7 @@ public partial class MainViewModel : ViewModelBase
[GenerateProperty] private DebugService DebugService { get; } = default!;
[GenerateProperty] private PopupMessageService PopupMessageService { get; } = default!;
[GenerateProperty] private ViewHelperService ViewHelperService { get; } = default!;
[GenerateProperty, DesignConstruct] private ViewHelperService ViewHelperService { get; } = default!;
public ObservableCollection<ListItemTemplate> Items { get; private set; }

View File

@@ -34,7 +34,7 @@ public partial class AccountInfoViewModel : ViewModelBase
[GenerateProperty] private PopupMessageService PopupMessageService { get; } = default!;
[GenerateProperty] private ConfigurationService ConfigurationService { get; } = default!;
[GenerateProperty] private AuthService AuthService { get; } = default!;
[GenerateProperty] private ViewHelperService ViewHelperService { get; } = default!;
[GenerateProperty, DesignConstruct] private ViewHelperService ViewHelperService { get; } = default!;
public ObservableCollection<AuthLoginPasswordModel> Accounts { get; } = new();
public ObservableCollection<string> AuthUrls { get; } = new();

View File

@@ -39,7 +39,7 @@ public sealed partial class ContentBrowserViewModel : ViewModelBase
[GenerateProperty] private DebugService DebugService { get; } = default!;
[GenerateProperty] private PopupMessageService PopupService { get; } = default!;
[GenerateProperty] private HubService HubService { get; } = default!;
[GenerateProperty] private ViewHelperService ViewHelperService { get; } = default!;
[GenerateProperty, DesignConstruct] private ViewHelperService ViewHelperService { get; } = default!;
public ObservableCollection<ContentEntry> Entries { get; } = new();

View File

@@ -19,7 +19,7 @@ public partial class ServerListViewModel : ViewModelBase
public Action? OnSearchChange;
[GenerateProperty] private HubService HubService { get; } = default!;
[GenerateProperty] private ViewHelperService ViewHelperService { get; } = default!;
[GenerateProperty, DesignConstruct] private ViewHelperService ViewHelperService { get; } = default!;
public ObservableCollection<ServerEntryModelView> ServerInfos { get; } = new();
private List<ServerHubInfo> UnsortedServers { get; } = new();

View File

@@ -38,9 +38,9 @@
PaneBackground="#00000000">
<SplitView.Pane>
<Border
Background="{StaticResource DefaultBackground}"
Background="{StaticResource DefaultForeground}"
BorderThickness="0,0,2,0"
CornerRadius="0,0,0,0"
CornerRadius="0,8,8,0"
Grid.Column="0"
Grid.Row="0"
Margin="0,0,5,0"
@@ -80,6 +80,7 @@
<Border
BorderThickness="0,2,0,0"
CornerRadius="0,0,0,0"
Background="{StaticResource DefaultForeground}"
Grid.Column="0"
Grid.ColumnSpan="2"
Grid.Row="1"
@@ -95,7 +96,7 @@
Margin="0"
Padding="0"
VerticalAlignment="Center">
<TextBlock HorizontalAlignment="Left" VerticalAlignment="Center">https://cinka.ru/nebula-launcher/</TextBlock>
<TextBlock Foreground="#777777" HorizontalAlignment="Left" VerticalAlignment="Center">https://cinka.ru/nebula-launcher/</TextBlock>
</Button>
<TextBlock HorizontalAlignment="Right" VerticalAlignment="Center">prototype-product-v0.01</TextBlock>
</Panel>

View File

@@ -20,13 +20,12 @@
RowDefinitions="*,40">
<ScrollViewer Margin="0,0,0,10" Padding="0,0,10,0" Grid.RowSpan="2">
<ItemsControl
Background="#00000000"
ItemsSource="{Binding ServerInfos}"
Padding="0">
</ItemsControl>
</ScrollViewer>
<Border Grid.Row="1" Background="{StaticResource DefaultBackground}" BoxShadow="none">
<Border Grid.Row="1" Background="{StaticResource DefaultBackground}" BorderThickness="0">
</Border>

View File

@@ -17,12 +17,14 @@
</Design.DataContext>
<Border
Background="#00000000"
BorderThickness="2,1,0,1"
Background="Transparent"
BorderThickness="3,1,0,1"
BorderBrush="{StaticResource DefaultForeground}"
CornerRadius="10"
Margin="5">
<Grid ColumnDefinitions="*,80,50" RowDefinitions="35,*,*">
<Border
BorderBrush="{StaticResource DefaultForeground}"
Background="#00000000"
BorderThickness="0,0,0,2"
CornerRadius="10"
@@ -96,7 +98,8 @@
</Label>
<Border
Background="#00000000"
BorderBrush="{StaticResource DefaultForeground}"
Background="Transparent"
BorderThickness="0,2,0,0"
CornerRadius="10"
Grid.Column="0"
@@ -111,8 +114,9 @@
<ItemsControl.ItemTemplate>
<DataTemplate DataType="{x:Type system:String}">
<Border
Background="#121212"
Background="{StaticResource DefaultForeground}"
CornerRadius="8"
BorderThickness="0"
HorizontalAlignment="Center"
Margin="1,1,1,1"
VerticalAlignment="Center">
@@ -136,8 +140,9 @@
<StackPanel Orientation="Horizontal" >
<Label FontSize="10" VerticalAlignment="Center">Map:</Label>
<Border
Background="#121212"
Background="{StaticResource DefaultForeground}"
CornerRadius="8"
BorderThickness="0"
HorizontalAlignment="Center"
Margin="5"
VerticalAlignment="Center">
@@ -150,8 +155,9 @@
<StackPanel Orientation="Horizontal">
<Label FontSize="10" VerticalAlignment="Center">Preset:</Label>
<Border
Background="#121212"
Background="{StaticResource DefaultForeground}"
CornerRadius="8"
BorderThickness="0"
HorizontalAlignment="Center"
Margin="5"
VerticalAlignment="Center">

View File

@@ -4,4 +4,9 @@ namespace Nebula.Shared.Attributes
public class GeneratePropertyAttribute : Attribute
{
}
[AttributeUsage(AttributeTargets.Property)]
public class DesignConstructAttribute : Attribute
{
}
}

View File

@@ -39,23 +39,28 @@ public class DependencyAutoGenerator : IIncrementalGenerator
var namespaceName = classSymbol.ContainingNamespace.ToDisplayString();
var className = classDeclarationSyntax.Identifier.Text;
var defaultConstruct = $@"public {className}(){{
InitialiseInDesignMode();
}}";
var propertiesGenerated = GetProperties(classSymbol).ToList();
var constr = propertiesGenerated.Select(a => $"{a.Type.ToDisplayString()} g{a.Name}");
var body = propertiesGenerated.Select(a => $"this.{a.Name} = g{a.Name};");
//if (!constr.Any()) defaultConstruct = "";
var propertiesGeneratedC = GetProperties(classSymbol)
.Where(a=>
SourceHelper.HasAttribute(a,"Nebula.Shared.Attributes.DesignConstructAttribute"))
.ToList();
var bodyC = propertiesGeneratedC.Select(a => $"this.{a.Name} = new {a.Type.ToDisplayString()}();");
var code = $@"// <auto-generated/>
namespace {namespaceName};
partial class {className}
{{
{defaultConstruct}
public {className}(){{
{string.Join("\n\t\t", bodyC)}
InitialiseInDesignMode();
}}
public {className}(
{string.Join(",\n\t\t", constr)}
) : base(){{