Skip to content
This repository has been archived by the owner on Jun 6, 2023. It is now read-only.

Commit

Permalink
Update MessageBox
Browse files Browse the repository at this point in the history
  • Loading branch information
Onebeld committed May 29, 2021
1 parent 8f4726e commit 6a8304c
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 66 deletions.
6 changes: 3 additions & 3 deletions src/OlibUI.Sample/FileSettings.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
using System;
using System.IO;
using System.Text.Json;
using Newtonsoft.Json;
using OlibUI.Sample.Structures;

namespace OlibUI.Sample
{
public static class FileSettings
{
public static Settings LoadSettings() => JsonSerializer.Deserialize<Settings>(File.ReadAllText(AppDomain.CurrentDomain.BaseDirectory + "settings.json"));
public static Settings LoadSettings() => JsonConvert.DeserializeObject<Settings>(File.ReadAllText(AppDomain.CurrentDomain.BaseDirectory + "settings.json"));

public static void SaveSettings() => File.WriteAllText(AppDomain.CurrentDomain.BaseDirectory + "settings.json", JsonSerializer.Serialize(Program.Settings));
public static void SaveSettings() => File.WriteAllText(AppDomain.CurrentDomain.BaseDirectory + "settings.json", JsonConvert.SerializeObject(Program.Settings));
}
}
10 changes: 5 additions & 5 deletions src/OlibUI.Sample/ViewModels/MainWindowViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@
using OlibUI.Structures;
using OlibUI.Windows;
using System;
using System.Collections.ObjectModel;
using System.IO;
using System.Linq;
using System.Runtime.Serialization;
using Newtonsoft.Json;
using OlibUI.Sample.Views.Windows;
using System.Collections.Generic;
using Newtonsoft.Json;
using Avalonia.Collections;

namespace OlibUI.Sample.ViewModels
{
Expand All @@ -28,7 +28,7 @@ public class MainWindowViewModel : ViewModelBase
private bool _enableBlur;
private bool _enableMovablePopup;

private ObservableCollection<Theme> _customThemes = new ObservableCollection<Theme>();
private AvaloniaList<Theme> _customThemes = new AvaloniaList<Theme>();

private Theme _customTheme;

Expand Down Expand Up @@ -72,7 +72,7 @@ private int Theme
}

[DataMember]
private ObservableCollection<Theme> CustomThemes
private AvaloniaList<Theme> CustomThemes
{
get => _customThemes;
set => RaiseAndSetIfChanged(ref _customThemes, value);
Expand Down Expand Up @@ -327,7 +327,7 @@ private void ShowMessageBox()
{
Text = "OK", Result = "OK", IsKeyDown = true
}
}, MessageBox.MessageBoxIcon.Information);
}, MessageBox.MessageBoxIcon.Information, "sdafdsfdsdfadsf");
}
}
}
42 changes: 0 additions & 42 deletions src/OlibUI.Sample/ViewModels/ViewModelBase.cs

This file was deleted.

2 changes: 1 addition & 1 deletion src/OlibUI/OlibUI.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<Version>2.2.0</Version>
<Version>2.2.1</Version>
<Authors>Dmitry Zhutkov (Onebeld)</Authors>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
Expand Down
24 changes: 12 additions & 12 deletions src/OlibUI/Structures/Theme.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,55 +31,55 @@ public string Name
}

[DataMember]
public Color BackgroundColor
public Color BackgroundColor
{
get => _backgroundColor;
set => RaiseAndSetIfChanged(ref _backgroundColor, value);
}
[DataMember]
public Color HoverBackgroundColor
public Color HoverBackgroundColor
{
get => _hoverBackgroundColor;
set => RaiseAndSetIfChanged(ref _hoverBackgroundColor, value);
}
[DataMember]
public Color ForegroundColor
public Color ForegroundColor
{
get => _foregroundColor;
set => RaiseAndSetIfChanged(ref _foregroundColor, value);
}
[DataMember]
public Color ForegroundOpacityColor
public Color ForegroundOpacityColor
{
get => _foregroundOpacityColor;
set => RaiseAndSetIfChanged(ref _foregroundOpacityColor, value);
}
[DataMember]
public Color PressedForegroundColor
public Color PressedForegroundColor
{
get => _pressedForegroundColor;
set => RaiseAndSetIfChanged(ref _pressedForegroundColor, value);
}
[DataMember]
public Color AccentColor
public Color AccentColor
{
get => _accentColor;
set => RaiseAndSetIfChanged(ref _accentColor, value);
}
[DataMember]
public Color BorderBackgroundColor
public Color BorderBackgroundColor
{
get => _borderBackgroundColor;
set => RaiseAndSetIfChanged(ref _borderBackgroundColor, value);
}
[DataMember]
public Color BorderColor
public Color BorderColor
{
get => _borderColor;
set => RaiseAndSetIfChanged(ref _borderColor, value);
}
[DataMember]
public Color WindowBorderColor
public Color WindowBorderColor
{
get => _windowBorderColor;
set => RaiseAndSetIfChanged(ref _windowBorderColor, value);
Expand All @@ -91,19 +91,19 @@ public Color NotActiveWindowBorderColor
set => RaiseAndSetIfChanged(ref _notActiveWindowBorderColor, value);
}
[DataMember]
public Color HoverScrollBoxColor
public Color HoverScrollBoxColor
{
get => _hoverScrollBoxColor;
set => RaiseAndSetIfChanged(ref _hoverScrollBoxColor, value);
}
[DataMember]
public Color ScrollBoxColor
public Color ScrollBoxColor
{
get => _scrollBoxColor;
set => RaiseAndSetIfChanged(ref _scrollBoxColor, value);
}
[DataMember]
public Color ErrorColor
public Color ErrorColor
{
get => _errorColor;
set => RaiseAndSetIfChanged(ref _errorColor, value);
Expand Down
4 changes: 2 additions & 2 deletions src/OlibUI/Windows/MessageBox.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@
ShowInTaskbar="False"
x:Class="OlibUI.Windows.MessageBox"
SizeToContent="WidthAndHeight" CanResize="False">
<Grid Name="ContentC" RowDefinitions="*,Auto">
<Grid Name="ContentC" RowDefinitions="*,*">
<Grid Name="Content" ColumnDefinitions="70,*">
<Path Name="Icon" Fill="{StaticResource ForegroundBrush}" VerticalAlignment="Center" Stretch="Uniform" Width="40" Margin="10"/>
<ScrollViewer Grid.Column="1">
<TextBlock VerticalAlignment="Center" Name="Text" TextWrapping="Wrap" Margin="0 0 10 0" Width="250"/>
</ScrollViewer>
</Grid>
<TextBox Name="ErrorText" Height="100" MaxWidth="450" Grid.Row="1" Margin="10" AcceptsReturn="True" TextWrapping="Wrap" IsReadOnly="True"/>
<TextBox Name="ErrorText" MinHeight="50" Grid.Row="1" Margin="10" AcceptsReturn="True" TextWrapping="Wrap" IsReadOnly="True"/>
</Grid>
<OlibWindow.BottomPanel>
<StackPanel HorizontalAlignment="Right" Orientation="Horizontal" Name="Buttons" Spacing="5"/>
Expand Down
7 changes: 6 additions & 1 deletion src/OlibUI/Windows/MessageBox.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,20 +33,25 @@ public enum MessageBoxIcon
/// <param name="icon">Message box icon</param>
/// <param name="textException">Adding additional information</param>
/// <returns>Result after pressing the button</returns>
public static Task<string> Show(Window parent, string title, string text, IList<MessageBoxButton> buttons, MessageBoxIcon icon = MessageBoxIcon.None, string textException = null)
public static Task<string> Show(Window parent, string title, string text, IList<MessageBoxButton> buttons, MessageBoxIcon icon = MessageBoxIcon.None, string textException = null, double maxWidth = 450, double maxHeight = 200)
{
MessageBox msgbox = new MessageBox
{
Title = title,
Icon = parent?.Icon,
CompactMode = ((OlibWindow)parent)?.CompactMode ?? false,
EnableBlur = ((OlibWindow)parent)?.EnableBlur ?? true,
MaxHeight = maxHeight,
MaxWidth = maxWidth
};
msgbox.FindControl<TextBlock>("Text").Text = text;
StackPanel buttonPanel = msgbox.FindControl<StackPanel>("Buttons");
Path iconControl = msgbox.FindControl<Path>("Icon");
TextBox errorText = msgbox.FindControl<TextBox>("ErrorText");

errorText.MaxHeight = maxHeight - 130;
errorText.MaxWidth = maxWidth - 5;

string res = "OK";

void AddButton(MessageBoxButton r)
Expand Down

0 comments on commit 6a8304c

Please sign in to comment.