Skip to content
This repository was archived by the owner on Nov 27, 2024. It is now read-only.

Commit cb9fa44

Browse files
committed
GUI WindowLogger
1 parent d60d421 commit cb9fa44

File tree

5 files changed

+128
-8
lines changed

5 files changed

+128
-8
lines changed

OnnxStack.UI/MainWindow.xaml

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
<TextBlock Text="Text To Image" Margin="5,0,0,0"/>
3434
</StackPanel>
3535
</TabItem.Header>
36-
<views:TextToImageView />
36+
<views:TextToImageView Margin="0,10,0,0"/>
3737
</TabItem>
3838

3939
<!--Image To Image-->
@@ -48,7 +48,7 @@
4848
<TextBlock Text="Image To Image" Margin="5,0,0,0"/>
4949
</StackPanel>
5050
</TabItem.Header>
51-
<views:ImageToImage />
51+
<views:ImageToImage Margin="0,10,0,0"/>
5252
</TabItem>
5353

5454
<!--Image Inpaint-->
@@ -63,7 +63,20 @@
6363
<TextBlock Text="Image Inpaint" Margin="5,0,0,0"/>
6464
</StackPanel>
6565
</TabItem.Header>
66-
<views:ImageInpaint />
66+
<views:ImageInpaint Margin="0,10,0,0"/>
67+
</TabItem>
68+
69+
<!--Log Window-->
70+
<TabItem DockPanel.Dock="Right" HorizontalAlignment="Right">
71+
<TabItem.Header>
72+
<StackPanel Orientation="Horizontal" Margin="5">
73+
<StackPanel Orientation="Horizontal">
74+
<userControls:FontAwesome Icon="&#xf022;" IconStyle="Light"/>
75+
</StackPanel>
76+
<TextBlock Text="Logs" Margin="5,0,0,0"/>
77+
</StackPanel>
78+
</TabItem.Header>
79+
<views:Logger LogOutput="{Binding OutputLog, Mode=TwoWay}" Margin="0,10,0,0"/>
6780
</TabItem>
6881

6982
<!--Settings-->
@@ -76,9 +89,8 @@
7689
<TextBlock Text="Settings" Margin="5,0,0,0"/>
7790
</StackPanel>
7891
</TabItem.Header>
79-
<views:Settings ModelOptions="{Binding Models, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged, NotifyOnSourceUpdated=True, NotifyOnTargetUpdated=True}" />
92+
<views:Settings ModelOptions="{Binding Models, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged, NotifyOnSourceUpdated=True, NotifyOnTargetUpdated=True}" Margin="0,10,0,0"/>
8093
</TabItem>
81-
8294
</TabControl>
8395
</Grid>
8496
</Window>

OnnxStack.UI/Utils.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,8 @@ public static SchedulerOptions ToSchedulerOptions(this SchedulerOptionsModel mod
101101
TrainedBetas = model.TrainedBetas,
102102
TrainTimesteps = model.TrainTimesteps,
103103
UseKarrasSigmas = model.UseKarrasSigmas,
104-
VarianceType = model.VarianceType
104+
VarianceType = model.VarianceType,
105+
OriginalInferenceSteps = model.OriginalInferenceSteps
105106
};
106107
}
107108

@@ -131,7 +132,8 @@ public static SchedulerOptionsModel ToSchedulerOptionsModel(this SchedulerOption
131132
TrainedBetas = model.TrainedBetas,
132133
TrainTimesteps = model.TrainTimesteps,
133134
UseKarrasSigmas = model.UseKarrasSigmas,
134-
VarianceType = model.VarianceType
135+
VarianceType = model.VarianceType,
136+
OriginalInferenceSteps = model.OriginalInferenceSteps,
135137
};
136138
}
137139

OnnxStack.UI/Views/Logger.xaml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<UserControl x:Class="OnnxStack.UI.Views.Logger"
2+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4+
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
5+
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
6+
xmlns:scm="clr-namespace:System.ComponentModel;assembly=WindowsBase"
7+
xmlns:local="clr-namespace:OnnxStack.UI.Views"
8+
xmlns:userControls="clr-namespace:OnnxStack.UI.UserControls"
9+
mc:Ignorable="d"
10+
d:DesignHeight="450" d:DesignWidth="800" Name="UI">
11+
<Grid DataContext="{Binding ElementName=UI}">
12+
<DockPanel>
13+
<DockPanel DockPanel.Dock="Bottom" HorizontalAlignment="Right">
14+
<StackPanel Orientation="Horizontal" Margin="0,4,0,0">
15+
<Button Command="{Binding ResetCommand}" Padding="10,3" Height="30">
16+
<userControls:FontAwesome Icon="&#xf2ed;" IconStyle="Light"/>
17+
</Button>
18+
</StackPanel>
19+
</DockPanel>
20+
<ScrollViewer HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Visible" CanContentScroll="False">
21+
<TextBox Style="{x:Null}" Text="{Binding LogOutput}" BorderThickness="0" TextWrapping="Wrap" IsReadOnly="True"/>
22+
</ScrollViewer>
23+
</DockPanel>
24+
</Grid>
25+
</UserControl>

OnnxStack.UI/Views/Logger.xaml.cs

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
using OnnxStack.UI.Commands;
2+
using OnnxStack.UI.Models;
3+
using System;
4+
using System.ComponentModel;
5+
using System.Runtime.CompilerServices;
6+
using System.Threading.Tasks;
7+
using System.Windows;
8+
using System.Windows.Controls;
9+
10+
namespace OnnxStack.UI.Views
11+
{
12+
/// <summary>
13+
/// Interaction logic for Logger.xaml
14+
/// </summary>
15+
public partial class Logger : UserControl, INavigatable, INotifyPropertyChanged
16+
{
17+
18+
/// <summary>
19+
/// Initializes a new instance of the <see cref="Logger"/> class.
20+
/// </summary>
21+
public Logger()
22+
{
23+
ResetCommand = new AsyncRelayCommand(Reset, CanExecuteReset);
24+
InitializeComponent();
25+
}
26+
27+
public AsyncRelayCommand ResetCommand { get; }
28+
29+
30+
/// <summary>
31+
/// Gets or sets the log output.
32+
/// </summary>
33+
public string LogOutput
34+
{
35+
get { return (string)GetValue(LogOutputProperty); }
36+
set { SetValue(LogOutputProperty, value); }
37+
}
38+
public static readonly DependencyProperty LogOutputProperty =
39+
DependencyProperty.Register("LogOutput", typeof(string), typeof(Logger));
40+
41+
42+
public Task NavigateAsync(ImageResult imageResult)
43+
{
44+
throw new NotImplementedException();
45+
}
46+
47+
48+
/// <summary>
49+
/// Resets the log window.
50+
/// </summary>
51+
/// <returns></returns>
52+
private Task Reset()
53+
{
54+
LogOutput = null;
55+
return Task.CompletedTask;
56+
}
57+
58+
59+
/// <summary>
60+
/// Determines whether this instance can execute reset.
61+
/// </summary>
62+
/// <returns>
63+
/// <c>true</c> if this instance can execute reset; otherwise, <c>false</c>.
64+
/// </returns>
65+
private bool CanExecuteReset()
66+
{
67+
return !string.IsNullOrEmpty(LogOutput);
68+
}
69+
70+
#region INotifyPropertyChanged
71+
public event PropertyChangedEventHandler PropertyChanged;
72+
73+
public void NotifyPropertyChanged([CallerMemberName] string property = "")
74+
{
75+
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(property));
76+
}
77+
#endregion
78+
}
79+
80+
81+
}

OnnxStack.UI/WindowLogger.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public void Log<TState>(LogLevel logLevel, EventId eventId, TState state, Except
4747
if (!IsEnabled(logLevel))
4848
return;
4949

50-
//Utils.LogToWindow($"[{DateTime.Now}] [{logLevel}] - {formatter(state, exception)}\n");
50+
Utils.LogToWindow($"[{DateTime.Now}] [{logLevel}] - {formatter(state, exception)}\n");
5151
}
5252

5353

0 commit comments

Comments
 (0)