Cosmos/source/Cosmos.Build.Windows/BuildUC.xaml.cs
kudzu_cp 3bc32e32ef
2008-09-20 02:15:20 +00:00

69 lines
2.2 KiB
C#

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using Indy.IL2CPU;
using System.Collections.ObjectModel;
using System.Windows.Threading;
namespace Cosmos.Build.Windows {
public partial class BuildUC : UserControl {
public BuildUC() {
InitializeComponent();
}
protected Builder mBuilder;
public void BeginBuild(Builder aBuilder, DebugModeEnum aDebugMode, byte aComPort) {
mBuilder = aBuilder;
aBuilder.ProgressChanged += DoProgressMessage;
aBuilder.CompileCompleted += new Action(aBuilder_CompileCompleted);
aBuilder.BeginCompile(aDebugMode, aComPort);
}
public event Action CompileCompleted;
protected void aBuilder_CompileCompleted() {
Dispatcher.BeginInvoke(
(Action)delegate() {
mBuilder.ProgressChanged -= DoProgressMessage;
CompileCompleted.Invoke();
}
);
}
public void DoDebugMessage(LogSeverityEnum aSeverity, string aMessage) {
if (aSeverity == LogSeverityEnum.Informational) {
return;
}
}
protected void ProgressMessageReceived(string aMsg) {
listProgress.SelectedIndex = listProgress.Items.Add(aMsg);
listProgress.ScrollIntoView(listProgress.Items[listProgress.SelectedIndex]);
}
public void DoProgressMessage(int aMax, int aCurrent, string aMessage) {
var xAction = (Action)delegate() {
ProgressMessageReceived(aMessage);
};
// Do not use BeginInvoke - if BeginInvoke is used these stack up
// and continue to come in and tie up the main thread after the engine completes
// and the window is closed
Dispatcher.Invoke(DispatcherPriority.Input, xAction);
}
}
}