blob: 50d98466f70f475295475b649b6a25af464f7980 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Foundation;
using AppKit;
namespace macdoc
{
public partial class AppleDocMergeWindowController : AppKit.NSWindowController
{
public AppleDocMergeWindowController (IntPtr handle) : base (handle)
{
Initialize ();
}
public AppleDocMergeWindowController () : base ("AppleDocMergeWindow")
{
Initialize ();
}
void Initialize ()
{
}
public override void WindowDidLoad ()
{
ProgressWidget.StartAnimation (this);
}
public void TrackProcessTask (Task<int> task)
{
task.ContinueWith (t => {
var faulted = t.IsFaulted;
if (faulted)
Logger.LogError ("Merger exception", t.Exception);
BeginInvokeOnMainThread (() => Finish (faulted || t.Result > 0, faulted ? 99 : t.Result));
});
}
void Finish (bool errored, int code)
{
ProgressWidget.Hidden = true;
WizardButton.Hidden = false;
if (errored) {
WizardText.StringValue = string.Format ("There was a problem running the update (code {0}).", code);
WizardButton.Title = "Close";
WizardButton.Activated += CloseCallback;
} else {
WizardText.StringValue = "Update successful. Restart MacDoc for changes to take effect.";
WizardButton.Title = "Restart MacDoc";
WizardButton.Activated += RestartCallback;
}
}
void CloseCallback (object sender, EventArgs e)
{
Close ();
}
void RestartCallback (object sender, EventArgs e)
{
AppDelegate.RestartRequested = true;
NSApplication.SharedApplication.Terminate (this);
}
public new AppleDocMergeWindow Window {
get {
return (AppleDocMergeWindow)base.Window;
}
}
}
}
|