Clean logbox on start

This commit is contained in:
mashed-potatoes 2020-06-29 13:13:02 +05:00
parent bdc4efe03a
commit 5aaa1fa6a4
3 changed files with 33 additions and 3 deletions

View file

@ -73,6 +73,17 @@ namespace PotatoNV_next.Controls
}
}
public void Clear()
{
if (!Dispatcher.CheckAccess())
{
Dispatcher.Invoke(() => Clear());
return;
}
logBox.Clear();
}
public LogBox()
{
InitializeComponent();

View file

@ -37,6 +37,6 @@
</TabItem>
</TabControl>
<controls:LogBox />
<controls:LogBox x:Name="logBox" />
</UniformGrid>
</Window>

View file

@ -2,6 +2,7 @@
using PotatoNV_next.Utils;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
@ -19,15 +20,33 @@ namespace PotatoNV_next
{
public partial class MainWindow : Window
{
Core core = new Core();
public MainWindow()
{
Icon = MediaConverter.ImageSourceFromBitmap(Properties.Resources.Fire.ToBitmap());
InitializeComponent();
var core = new Core();
nvFrom.OnFormSubmit += core.StartProcess;
nvFrom.OnFormSubmit += NvFrom_OnFormSubmit;
core.RunWorkerCompleted += Core_RunWorkerCompleted;
SetupLog();
}
private void NvFrom_OnFormSubmit(Controls.NVForm.FormEventArgs formEventArgs)
{
SetupLog();
core.StartProcess(formEventArgs);
}
public void SetupLog()
{
logBox.Clear();
Log.Info($"PotatoNV v{Controls.AboutTab.GetVersion()}");
Log.Info("User manual: https://kutt.it/pnv-"
+ (CultureInfo.InstalledUICulture.TwoLetterISOLanguageName == "ru"
? "ru"
: "en"));
}
private void Core_RunWorkerCompleted()