상속: NSWindowDelegate
예제 #1
0
        // TODO: Window needs to be made resizable
        public SparkleEventLog()
            : base()
        {
            Title    = "Recent Events";
            Delegate = new SparkleEventsDelegate ();

            SetFrame (new RectangleF (0, 0, 480, 640), true);
            Center ();

            StyleMask = (NSWindowStyle.Closable |
                         NSWindowStyle.Miniaturizable |
                         NSWindowStyle.Titled);

            MaxSize     = new SizeF (480, 640);
            MinSize     = new SizeF (480, 640);
            HasShadow   = true;
            BackingType = NSBackingStore.Buffered;

            ContentView.AddSubview (Separator);

            this.progress_indicator = new NSProgressIndicator () {
                Style = NSProgressIndicatorStyle.Spinning,
                Frame = new RectangleF (this.web_view.Frame.Width / 2 - 10, this.web_view.Frame.Height / 2 + 10, 20, 20)
            };

            this.progress_indicator.StartAnimation (this);
            ContentView.AddSubview (this.progress_indicator);

            UpdateContent (null);
            UpdateChooser (null);
            OrderFrontRegardless ();

            // Hook up the controller events
            this.controller.UpdateChooserEvent += delegate (string [] folders) {
                InvokeOnMainThread (delegate {
                    UpdateChooser (folders);
                });
            };

            this.controller.UpdateContentEvent += delegate (string html) {
                InvokeOnMainThread (delegate {
                    UpdateContent (html);
                });
            };

            this.controller.ContentLoadingEvent += delegate {
                InvokeOnMainThread (delegate {
                    if (this.web_view.Superview == ContentView)
                        this.web_view.RemoveFromSuperview ();

                    ContentView.AddSubview (this.progress_indicator);
                });
            };
        }
예제 #2
0
        public SparkleEventLog()
            : base()
        {
            Title    = "Recent Events";
            Delegate = new SparkleEventsDelegate ();

            SetFrame (new RectangleF (0, 0, 480, 640), true);
            Center ();

            StyleMask = (NSWindowStyle.Closable |
                         NSWindowStyle.Miniaturizable |
                         NSWindowStyle.Titled);

            MaxSize     = new SizeF (480, 640);
            MinSize     = new SizeF (480, 640);
            HasShadow   = true;
            BackingType = NSBackingStore.Buffered;

            CreateEvents ();
            UpdateEvents (false);
            UpdateChooser ();

            OrderFrontRegardless ();
        }
예제 #3
0
        public SparkleEventLog()
            : base()
        {
            using (var a = new NSAutoreleasePool ())
            {
                Title    = "Recent Changes";
                Delegate = new SparkleEventsDelegate ();

                int min_width  = 480;
                int min_height = 640;
                float x    = (float) (NSScreen.MainScreen.Frame.Width * 0.61);
                float y    = (float) (NSScreen.MainScreen.Frame.Height * 0.5 - (min_height * 0.5));

                SetFrame (
                    new RectangleF (
                        new PointF (x, y),
                        new SizeF (min_width, (int) (NSScreen.MainScreen.Frame.Height * 0.85))),
                    true);

                StyleMask = (NSWindowStyle.Closable |
                             NSWindowStyle.Miniaturizable |
                             NSWindowStyle.Titled |
                             NSWindowStyle.Resizable);

                MinSize        = new SizeF (min_width, min_height);
                HasShadow      = true;
                BackingType    = NSBackingStore.Buffered;
                TitlebarHeight = Frame.Height - ContentView.Frame.Height;

                this.web_view = new WebView (new RectangleF (0, 0, 481, 579), "", "") {
                    PolicyDelegate = new SparkleWebPolicyDelegate (),
                    Frame = new RectangleF (new PointF (0, 0),
                        new SizeF (ContentView.Frame.Width, ContentView.Frame.Height - 39))
                };

                this.hidden_close_button = new NSButton () {
                    KeyEquivalentModifierMask = NSEventModifierMask.CommandKeyMask,
                    KeyEquivalent = "w"
                };

                this.hidden_close_button.Activated += delegate {
                    Controller.WindowClosed ();
                };

                this.size_label = new NSTextField () {
                    Alignment       = NSTextAlignment.Right,
                    BackgroundColor = NSColor.WindowBackground,
                    Bordered        = false,
                    Editable        = false,
                    Frame           = new RectangleF (
                        new PointF (0, ContentView.Frame.Height - 30),
                        new SizeF (60, 20)),
                    StringValue     = "Size:",
                    Font            = SparkleUI.BoldFont
                };

                this.size_label_value = new NSTextField () {
                    Alignment       = NSTextAlignment.Left,
                    BackgroundColor = NSColor.WindowBackground,
                    Bordered        = false,
                    Editable        = false,
                    Frame           = new RectangleF (
                        new PointF (60, ContentView.Frame.Height - 30),
                        new SizeF (60, 20)),
                    StringValue     = "…",
                    Font            = SparkleUI.Font
                };

                this.history_label = new NSTextField () {
                    Alignment       = NSTextAlignment.Right,
                    BackgroundColor = NSColor.WindowBackground,
                    Bordered        = false,
                    Editable        = false,
                    Frame           = new RectangleF (
                        new PointF (130, ContentView.Frame.Height - 30),
                        new SizeF (60, 20)),
                    StringValue     = "History:",
                    Font            = SparkleUI.BoldFont
                };

                this.history_label_value = new NSTextField () {
                    Alignment       = NSTextAlignment.Left,
                    BackgroundColor = NSColor.WindowBackground,
                    Bordered        = false,
                    Editable        = false,
                    Frame           = new RectangleF (
                        new PointF (190, ContentView.Frame.Height - 30),
                        new SizeF (60, 20)
                    ),
                    StringValue     = "…",
                    Font            = SparkleUI.Font
                };

                this.popup_button = new NSPopUpButton () {
                    Frame = new RectangleF (
                        new PointF (ContentView.Frame.Width - 156 - 12, ContentView.Frame.Height - 33),
                        new SizeF (156, 26)),
                    PullsDown = false
                };

                this.background = new NSBox () {
                    Frame = new RectangleF (
                        new PointF (-1, -1),
                        new SizeF (Frame.Width + 2, this.web_view.Frame.Height + 2)),
                    FillColor = NSColor.White,
                    BorderColor = NSColor.LightGray,
                    BoxType = NSBoxType.NSBoxCustom
                };

                this.progress_indicator = new NSProgressIndicator () {
                    Frame = new RectangleF (
                        new PointF (Frame.Width / 2 - 10, this.web_view.Frame.Height / 2 + 10),
                        new SizeF (20, 20)),
                    Style = NSProgressIndicatorStyle.Spinning
                };

                this.progress_indicator.StartAnimation (this);

                ContentView.AddSubview (this.size_label);
                ContentView.AddSubview (this.size_label_value);
                ContentView.AddSubview (this.history_label);
                ContentView.AddSubview (this.history_label_value);
                ContentView.AddSubview (this.popup_button);
                ContentView.AddSubview (this.progress_indicator);
                ContentView.AddSubview (this.background);
                ContentView.AddSubview (this.hidden_close_button);

                (this.web_view.PolicyDelegate as SparkleWebPolicyDelegate).LinkClicked += delegate (string href) {
                    Controller.LinkClicked (href);
                };

                (Delegate as SparkleEventsDelegate).WindowResized += Relayout;
            }

            // Hook up the controller events
            Controller.HideWindowEvent += delegate {
                using (var a = new NSAutoreleasePool ())
                {
                    InvokeOnMainThread (delegate {
                        PerformClose (this);

                        if (this.web_view.Superview == ContentView)
                            this.web_view.RemoveFromSuperview ();
                    });
                }
            };

            Controller.ShowWindowEvent += delegate {
                using (var a = new NSAutoreleasePool ())
                {
                    InvokeOnMainThread (delegate {
                        OrderFrontRegardless ();
                    });
                }
            };

            Controller.UpdateChooserEvent += delegate (string [] folders) {
                using (var a = new NSAutoreleasePool ())
                {
                    InvokeOnMainThread (delegate {
                        UpdateChooser (folders);
                    });
                }
            };

            Controller.UpdateContentEvent += delegate (string html) {
                using (var a = new NSAutoreleasePool ())
                {
                    InvokeOnMainThread (delegate {
                        UpdateContent (html);
                    });
                }
            };

            Controller.ContentLoadingEvent += delegate {
                using (var a = new NSAutoreleasePool ())
                {
                    InvokeOnMainThread (delegate {
                        if (this.web_view.Superview == ContentView)
                            this.web_view.RemoveFromSuperview ();

                        ContentView.AddSubview (this.progress_indicator);
                    });
                }
            };

            Controller.UpdateSizeInfoEvent += delegate (string size, string history_size) {
                using (var a = new NSAutoreleasePool ())
                {
                    InvokeOnMainThread (delegate {
                        this.size_label_value.StringValue    = size;
                        this.history_label_value.StringValue = history_size;
                    });
                }
            };
        }
예제 #4
0
        // TODO: Window needs to be made resizable
        public SparkleEventLog()
            : base()
        {
            Title    = "Recent Events";

            Delegate = new SparkleEventsDelegate ();

            SetFrame (new RectangleF (0, 0, 480, 640), true);
            Center ();

            StyleMask = (NSWindowStyle.Closable |
                         NSWindowStyle.Miniaturizable |
                         NSWindowStyle.Titled);

            MaxSize     = new SizeF (480, 640);
            MinSize     = new SizeF (480, 640);
            HasShadow   = true;
            BackingType = NSBackingStore.Buffered;

            this.hidden_close_button = new NSButton () {
                Frame                     = new RectangleF (0, 0, 0, 0),
                KeyEquivalentModifierMask = NSEventModifierMask.CommandKeyMask,
                KeyEquivalent             = "w"
            };

            this.hidden_close_button.Activated += delegate {
                Controller.WindowClosed ();
            };

            ContentView.AddSubview (this.hidden_close_button);

            this.size_label = new NSTextField () {
                Alignment       = NSTextAlignment.Right,
                BackgroundColor = NSColor.WindowBackground,
                Bordered        = false,
                Editable        = false,
                Frame           = new RectangleF (0, 588, 60, 20),
                StringValue     = "Size:",
                Font            = SparkleUI.BoldFont
            };

            this.size_label_value = new NSTextField () {
                Alignment       = NSTextAlignment.Left,
                BackgroundColor = NSColor.WindowBackground,
                Bordered        = false,
                Editable        = false,
                Frame           = new RectangleF (60, 588, 75, 20),
                StringValue     = "…",
                Font            = SparkleUI.Font
            };

            this.history_label = new NSTextField () {
                Alignment       = NSTextAlignment.Right,
                BackgroundColor = NSColor.WindowBackground,
                Bordered        = false,
                Editable        = false,
                Frame           = new RectangleF (130, 588, 60, 20),
                StringValue     = "History:",
                Font            = SparkleUI.BoldFont
            };

            this.history_label_value = new NSTextField () {
                Alignment       = NSTextAlignment.Left,
                BackgroundColor = NSColor.WindowBackground,
                Bordered        = false,
                Editable        = false,
                Frame           = new RectangleF (190, 588, 75, 20),
                StringValue     = "…",
                Font            = SparkleUI.Font
            };

            ContentView.AddSubview (this.size_label);
            ContentView.AddSubview (this.size_label_value);
            ContentView.AddSubview (this.history_label);
            ContentView.AddSubview (this.history_label_value);
            ContentView.AddSubview (this.separator);

            this.progress_indicator = new NSProgressIndicator () {
                Style = NSProgressIndicatorStyle.Spinning,
                Frame = new RectangleF (this.web_view.Frame.Width / 2 - 10,
                    this.web_view.Frame.Height / 2 + 10, 20, 20)
            };

            this.progress_indicator.StartAnimation (this);
            ContentView.AddSubview (this.progress_indicator);

            (this.web_view.PolicyDelegate as SparkleWebPolicyDelegate)
                .LinkClicked += delegate (string href) {
                    Controller.LinkClicked (href);
                };

            // Hook up the controller events
            Controller.HideWindowEvent += delegate {
                InvokeOnMainThread (delegate {
                    PerformClose (this);
                });
            };

            Controller.ShowWindowEvent += delegate {
                InvokeOnMainThread (delegate {
                    OrderFrontRegardless ();

                    UpdateContent (null);
                    UpdateChooser (null);
                });
            };

            Controller.UpdateChooserEvent += delegate (string [] folders) {
                InvokeOnMainThread (delegate {
                    UpdateChooser (folders);
                });
            };

            Controller.UpdateContentEvent += delegate (string html) {
                InvokeOnMainThread (delegate {
                    UpdateContent (html);
                });
            };

            Controller.ContentLoadingEvent += delegate {
                InvokeOnMainThread (delegate {
                    if (this.web_view.Superview == ContentView)
                        this.web_view.RemoveFromSuperview ();

                    ContentView.AddSubview (this.progress_indicator);
                });
            };

            Controller.UpdateSizeInfoEvent += delegate (string size, string history_size) {
                InvokeOnMainThread (delegate {
                    this.size_label_value.StringValue = size;
                    this.history_label_value.StringValue = history_size;
                });
            };
        }
예제 #5
0
        // TODO: Window needs to be made resizable
        public SparkleEventLog() : base()
        {
            Title    = "Recent Events";
            Delegate = new SparkleEventsDelegate();

            SetFrame(new RectangleF(0, 0, 480, 640), true);
            Center();

            StyleMask = (NSWindowStyle.Closable |
                         NSWindowStyle.Miniaturizable |
                         NSWindowStyle.Titled);

            MaxSize     = new SizeF(480, 640);
            MinSize     = new SizeF(480, 640);
            HasShadow   = true;
            BackingType = NSBackingStore.Buffered;


            this.size_label = new NSTextField()
            {
                Alignment       = NSTextAlignment.Right,
                BackgroundColor = NSColor.WindowBackground,
                Bordered        = false,
                Editable        = false,
                Frame           = new RectangleF(0, 588, 60, 20),
                StringValue     = "Size:",
                Font            = SparkleUI.BoldFont
            };

            this.size_label_value = new NSTextField()
            {
                Alignment       = NSTextAlignment.Left,
                BackgroundColor = NSColor.WindowBackground,
                Bordered        = false,
                Editable        = false,
                Frame           = new RectangleF(60, 588, 75, 20),
                StringValue     = Controller.Size,
                Font            = SparkleUI.Font
            };


            this.history_label = new NSTextField()
            {
                Alignment       = NSTextAlignment.Right,
                BackgroundColor = NSColor.WindowBackground,
                Bordered        = false,
                Editable        = false,
                Frame           = new RectangleF(130, 588, 60, 20),
                StringValue     = "History:",
                Font            = SparkleUI.BoldFont
            };

            this.history_label_value = new NSTextField()
            {
                Alignment       = NSTextAlignment.Left,
                BackgroundColor = NSColor.WindowBackground,
                Bordered        = false,
                Editable        = false,
                Frame           = new RectangleF(190, 588, 75, 20),
                StringValue     = Controller.HistorySize,
                Font            = SparkleUI.Font
            };


            ContentView.AddSubview(this.size_label);
            ContentView.AddSubview(this.size_label_value);
            ContentView.AddSubview(this.history_label);
            ContentView.AddSubview(this.history_label_value);
            ContentView.AddSubview(this.separator);


            this.progress_indicator = new NSProgressIndicator()
            {
                Style = NSProgressIndicatorStyle.Spinning,
                Frame = new RectangleF(this.web_view.Frame.Width / 2 - 10, this.web_view.Frame.Height / 2 + 10, 20, 20)
            };

            this.progress_indicator.StartAnimation(this);
            ContentView.AddSubview(this.progress_indicator);


            UpdateContent(null);
            UpdateChooser(null);
            OrderFrontRegardless();


            // Hook up the controller events
            Controller.UpdateChooserEvent += delegate(string [] folders) {
                InvokeOnMainThread(delegate {
                    UpdateChooser(folders);
                });
            };

            Controller.UpdateContentEvent += delegate(string html) {
                InvokeOnMainThread(delegate {
                    UpdateContent(html);
                });
            };

            Controller.ContentLoadingEvent += delegate {
                InvokeOnMainThread(delegate {
                    if (this.web_view.Superview == ContentView)
                    {
                        this.web_view.RemoveFromSuperview();
                    }

                    ContentView.AddSubview(this.progress_indicator);
                });
            };

            Controller.UpdateSizeInfoEvent += delegate(string size, string history_size) {
                InvokeOnMainThread(delegate {
                    this.size_label_value.StringValue    = size;
                    this.history_label_value.StringValue = history_size;
                });
            };
        }
예제 #6
0
        public SparkleEventLog()
            : base()
        {
            using (var a = new NSAutoreleasePool ())
            {
                Title    = "Recent Changes";
                Delegate = new SparkleEventsDelegate ();

                int min_width  = 480;
                int min_height = 640;
                float x    = (float) (NSScreen.MainScreen.Frame.Width * 0.61);
                float y    = (float) (NSScreen.MainScreen.Frame.Height * 0.5 - (min_height * 0.5));

                SetFrame (
                    new RectangleF (
                        new PointF (x, y),
                        new SizeF (min_width, (int) (NSScreen.MainScreen.Frame.Height * 0.85))),
                    true);

                StyleMask = (NSWindowStyle.Closable | NSWindowStyle.Miniaturizable |
                             NSWindowStyle.Titled | NSWindowStyle.Resizable);

                MinSize        = new SizeF (min_width, min_height);
                HasShadow      = true;
                BackingType    = NSBackingStore.Buffered;
                TitlebarHeight = Frame.Height - ContentView.Frame.Height;

                this.web_view = new WebView (new RectangleF (0, 0, 481, 579), "", "") {
                    Frame = new RectangleF (new PointF (0, 0),
                        new SizeF (ContentView.Frame.Width, ContentView.Frame.Height - 39))
                };

                this.hidden_close_button = new NSButton () {
                    KeyEquivalentModifierMask = NSEventModifierMask.CommandKeyMask,
                    KeyEquivalent = "w"
                };

                this.hidden_close_button.Activated += delegate {
                    Controller.WindowClosed ();
                };

                this.size_label = new NSTextField () {
                    Alignment       = NSTextAlignment.Right,
                    BackgroundColor = NSColor.WindowBackground,
                    Bordered        = false,
                    Editable        = false,
                    Frame           = new RectangleF (
                        new PointF (0, ContentView.Frame.Height - 30),
                        new SizeF (60, 20)),
                    StringValue     = "Size:",
                    Font            = SparkleUI.BoldFont
                };

                this.size_label_value = new NSTextField () {
                    Alignment       = NSTextAlignment.Left,
                    BackgroundColor = NSColor.WindowBackground,
                    Bordered        = false,
                    Editable        = false,
                    Frame           = new RectangleF (
                        new PointF (60, ContentView.Frame.Height - 30),
                        new SizeF (60, 20)),
                    StringValue     = "…",
                    Font            = SparkleUI.Font
                };

                this.history_label = new NSTextField () {
                    Alignment       = NSTextAlignment.Right,
                    BackgroundColor = NSColor.WindowBackground,
                    Bordered        = false,
                    Editable        = false,
                    Frame           = new RectangleF (
                        new PointF (130, ContentView.Frame.Height - 30),
                        new SizeF (60, 20)),
                    StringValue     = "History:",
                    Font            = SparkleUI.BoldFont
                };

                this.history_label_value = new NSTextField () {
                    Alignment       = NSTextAlignment.Left,
                    BackgroundColor = NSColor.WindowBackground,
                    Bordered        = false,
                    Editable        = false,
                    Frame           = new RectangleF (
                        new PointF (190, ContentView.Frame.Height - 30),
                        new SizeF (60, 20)
                    ),
                    StringValue     = "…",
                    Font            = SparkleUI.Font
                };

                this.popup_button = new NSPopUpButton () {
                    Frame = new RectangleF (
                        new PointF (ContentView.Frame.Width - 156 - 12, ContentView.Frame.Height - 33),
                        new SizeF (156, 26)),
                    PullsDown = false
                };

                this.background = new NSBox () {
                    Frame = new RectangleF (
                        new PointF (-1, -1),
                        new SizeF (Frame.Width + 2, this.web_view.Frame.Height + 2)),
                    FillColor = NSColor.White,
                    BorderColor = NSColor.LightGray,
                    BoxType = NSBoxType.NSBoxCustom
                };

                this.progress_indicator = new NSProgressIndicator () {
                    Frame = new RectangleF (
                        new PointF (Frame.Width / 2 - 10, this.web_view.Frame.Height / 2 + 10),
                        new SizeF (20, 20)),
                    Style = NSProgressIndicatorStyle.Spinning
                };

                this.progress_indicator.StartAnimation (this);

                ContentView.AddSubview (this.size_label);
                ContentView.AddSubview (this.size_label_value);
                ContentView.AddSubview (this.history_label);
                ContentView.AddSubview (this.history_label_value);
                ContentView.AddSubview (this.popup_button);
                ContentView.AddSubview (this.progress_indicator);
                ContentView.AddSubview (this.background);
                ContentView.AddSubview (this.hidden_close_button);

                (Delegate as SparkleEventsDelegate).WindowResized += Relayout;
            }

            // Hook up the controller events
            Controller.HideWindowEvent += delegate {
                using (var a = new NSAutoreleasePool ())
                {
                    InvokeOnMainThread (delegate {
                        this.progress_indicator.Hidden = true;
                        PerformClose (this);
                    });
                }
            };

            Controller.ShowWindowEvent += delegate {
                using (var a = new NSAutoreleasePool ())
                {
                    InvokeOnMainThread (delegate {
                        OrderFrontRegardless ();
                    });
                }
            };

            Controller.UpdateChooserEvent += delegate (string [] folders) {
                using (var a = new NSAutoreleasePool ())
                {
                    InvokeOnMainThread (delegate {
                        UpdateChooser (folders);
                    });
                }
            };

            Controller.UpdateChooserEnablementEvent += delegate (bool enabled) {
                using (var a = new NSAutoreleasePool ())
                {
                    InvokeOnMainThread (delegate {
                        this.popup_button.Enabled = enabled;
                    });
                }
            };

            Controller.UpdateContentEvent += delegate (string html) {
                using (var a = new NSAutoreleasePool ())
                {
                    InvokeOnMainThread (delegate {
                        this.progress_indicator.Hidden = true;
                        UpdateContent (html);
                    });
                }
            };

            Controller.ContentLoadingEvent += delegate {
                using (var a = new NSAutoreleasePool ())
                {
                    InvokeOnMainThread (delegate {
                        this.web_view.RemoveFromSuperview ();
                        this.progress_indicator.Hidden = false;

                        this.progress_indicator.StartAnimation (this);
                    });
                }
            };

            Controller.UpdateSizeInfoEvent += delegate (string size, string history_size) {
                using (var a = new NSAutoreleasePool ())
                {
                    InvokeOnMainThread (delegate {
                        this.size_label_value.StringValue    = size;
                        this.history_label_value.StringValue = history_size;
                    });
                }
            };

            Controller.ShowSaveDialogEvent += delegate (string file_name, string target_folder_path) {
                using (var a = new NSAutoreleasePool ())
                {
                    InvokeOnMainThread (() => {
                        // TODO: Make this a sheet
                        NSSavePanel panel = new NSSavePanel () {
                            DirectoryUrl         = new NSUrl (target_folder_path, true),
                            NameFieldStringValue = file_name,
                            ParentWindow         = this,
                            Title                = "Restore from History",
                            PreventsApplicationTerminationWhenModal = false
                        };

                        if ((NSPanelButtonType) panel.RunModal ()== NSPanelButtonType.Ok) {
                            string target_file_path = Path.Combine (panel.DirectoryUrl.RelativePath, panel.NameFieldStringValue);
                            Controller.SaveDialogCompleted (target_file_path);

                        } else {
                            Controller.SaveDialogCancelled ();
                        }
                    });
                }
            };
        }
예제 #7
0
        public SparkleEventLog() : base()
        {
            Title    = "Recent Changes";
            Delegate = new SparkleEventsDelegate();

            int min_width  = 480;
            int min_height = 640;
            int height     = (int)(NSScreen.MainScreen.Frame.Height * 0.85);

            float x = (float)(NSScreen.MainScreen.Frame.Width * 0.61);
            float y = (float)(NSScreen.MainScreen.Frame.Height * 0.5 - (height * 0.5));

            SetFrame(
                new RectangleF(
                    new PointF(x, y),
                    new SizeF(min_width, height)),
                true);

            StyleMask = (NSWindowStyle.Closable | NSWindowStyle.Miniaturizable |
                         NSWindowStyle.Titled | NSWindowStyle.Resizable);

            MinSize        = new SizeF(min_width, min_height);
            HasShadow      = true;
            BackingType    = NSBackingStore.Buffered;
            TitlebarHeight = Frame.Height - ContentView.Frame.Height;
            Level          = NSWindowLevel.Floating;


            this.web_view = new WebView(new RectangleF(0, 0, 481, 579), "", "")
            {
                Frame = new RectangleF(new PointF(0, 0),
                                       new SizeF(ContentView.Frame.Width, ContentView.Frame.Height - 39))
            };

            this.web_view.Preferences.PlugInsEnabled = false;

            this.cover = new NSBox()
            {
                Frame = new RectangleF(
                    new PointF(-1, -1),
                    new SizeF(Frame.Width + 2, this.web_view.Frame.Height + 1)),
                FillColor  = NSColor.White,
                BorderType = NSBorderType.NoBorder,
                BoxType    = NSBoxType.NSBoxCustom
            };

            this.hidden_close_button = new NSButton()
            {
                KeyEquivalentModifierMask = NSEventModifierMask.CommandKeyMask,
                KeyEquivalent             = "w"
            };

            this.hidden_close_button.Activated += delegate {
                Controller.WindowClosed();
            };


            this.size_label = new NSTextField()
            {
                Alignment       = NSTextAlignment.Right,
                BackgroundColor = NSColor.WindowBackground,
                Bordered        = false,
                Editable        = false,
                Frame           = new RectangleF(
                    new PointF(0, ContentView.Frame.Height - 31),
                    new SizeF(60, 20)),
                StringValue = "Size:"
            };

            this.size_label_value = new NSTextField()
            {
                Alignment       = NSTextAlignment.Left,
                BackgroundColor = NSColor.WindowBackground,
                Bordered        = false,
                Editable        = false,
                Frame           = new RectangleF(
                    new PointF(60, ContentView.Frame.Height - 27),
                    new SizeF(60, 20)),
                StringValue = "…",
                Font        = NSFont.FromFontName(SparkleUI.FontName + " Bold", NSFont.SystemFontSize)
            };


            this.history_label = new NSTextField()
            {
                Alignment       = NSTextAlignment.Right,
                BackgroundColor = NSColor.WindowBackground,
                Bordered        = false,
                Editable        = false,
                Frame           = new RectangleF(
                    new PointF(130, ContentView.Frame.Height - 31),
                    new SizeF(60, 20)),
                StringValue = "History:"
            };

            this.history_label_value = new NSTextField()
            {
                Alignment       = NSTextAlignment.Left,
                BackgroundColor = NSColor.WindowBackground,
                Bordered        = false,
                Editable        = false,
                Frame           = new RectangleF(
                    new PointF(190, ContentView.Frame.Height - 27),
                    new SizeF(60, 20)
                    ),
                StringValue = "…",
                Font        = NSFont.FromFontName(SparkleUI.FontName + " Bold", NSFont.SystemFontSize)
            };

            this.popup_button = new NSPopUpButton()
            {
                Frame = new RectangleF(
                    new PointF(ContentView.Frame.Width - 156 - 12, ContentView.Frame.Height - 33),
                    new SizeF(156, 26)),
                PullsDown = false
            };

            this.background = new NSBox()
            {
                Frame = new RectangleF(
                    new PointF(-1, -1),
                    new SizeF(Frame.Width + 2, this.web_view.Frame.Height + 2)),
                FillColor   = NSColor.White,
                BorderColor = NSColor.LightGray,
                BoxType     = NSBoxType.NSBoxCustom
            };

            this.progress_indicator = new NSProgressIndicator()
            {
                Frame = new RectangleF(
                    new PointF(Frame.Width / 2 - 10, this.web_view.Frame.Height / 2 + 10),
                    new SizeF(20, 20)),
                Style = NSProgressIndicatorStyle.Spinning
            };

            this.progress_indicator.StartAnimation(this);

            ContentView.AddSubview(this.size_label);
            ContentView.AddSubview(this.size_label_value);
            ContentView.AddSubview(this.history_label);
            ContentView.AddSubview(this.history_label_value);
            ContentView.AddSubview(this.popup_button);
            ContentView.AddSubview(this.progress_indicator);
            ContentView.AddSubview(this.background);
            ContentView.AddSubview(this.hidden_close_button);

            (Delegate as SparkleEventsDelegate).WindowResized += delegate(SizeF new_window_size) {
                Program.Controller.Invoke(() => Relayout(new_window_size));
            };


            // Hook up the controller events
            Controller.HideWindowEvent += delegate {
                Program.Controller.Invoke(() => {
                    this.progress_indicator.Hidden = true;
                    PerformClose(this);
                });
            };

            Controller.ShowWindowEvent += delegate {
                Program.Controller.Invoke(() => OrderFrontRegardless());
            };

            Controller.UpdateChooserEvent += delegate(string [] folders) {
                Program.Controller.Invoke(() => UpdateChooser(folders));
            };

            Controller.UpdateChooserEnablementEvent += delegate(bool enabled) {
                Program.Controller.Invoke(() => { this.popup_button.Enabled = enabled; });
            };

            Controller.UpdateContentEvent += delegate(string html) {
                Program.Controller.Invoke(() => {
                    this.cover.RemoveFromSuperview();
                    this.progress_indicator.Hidden = true;
                    UpdateContent(html);
                });
            };

            Controller.ContentLoadingEvent += delegate {
                Program.Controller.Invoke(() => {
                    this.web_view.RemoveFromSuperview();
                    // FIXME: Hack to hide that the WebView sometimes doesn't disappear
                    ContentView.AddSubview(this.cover);
                    this.progress_indicator.Hidden = false;
                    this.progress_indicator.StartAnimation(this);
                });
            };

            Controller.UpdateSizeInfoEvent += delegate(string size, string history_size) {
                Program.Controller.Invoke(() => {
                    this.size_label_value.StringValue    = size;
                    this.history_label_value.StringValue = history_size;
                });
            };

            Controller.ShowSaveDialogEvent += delegate(string file_name, string target_folder_path) {
                Program.Controller.Invoke(() => {
                    NSSavePanel panel = new NSSavePanel()
                    {
                        DirectoryUrl         = new NSUrl(target_folder_path, true),
                        NameFieldStringValue = file_name,
                        ParentWindow         = this,
                        Title = "Restore from History",
                        PreventsApplicationTerminationWhenModal = false
                    };

                    if ((NSPanelButtonType)panel.RunModal() == NSPanelButtonType.Ok)
                    {
                        string target_file_path = Path.Combine(panel.DirectoryUrl.RelativePath, panel.NameFieldStringValue);
                        Controller.SaveDialogCompleted(target_file_path);
                    }
                    else
                    {
                        Controller.SaveDialogCancelled();
                    }
                });
            };
        }
        // TODO: Window needs to be made resizable
        public SparkleEventLog()
            : base()
        {
            Title    = "Recent Events";
            Delegate = new SparkleEventsDelegate ();

            SetFrame (new RectangleF (0, 0, 480, 640), true);
            Center ();

            StyleMask = (NSWindowStyle.Closable |
                         NSWindowStyle.Miniaturizable |
                         NSWindowStyle.Titled);

            MaxSize     = new SizeF (480, 640);
            MinSize     = new SizeF (480, 640);
            HasShadow   = true;
            BackingType = NSBackingStore.Buffered;

            this.size_label = new NSTextField () {
                Alignment       = NSTextAlignment.Right,
                BackgroundColor = NSColor.WindowBackground,
                Bordered        = false,
                Editable        = false,
                Frame           = new RectangleF (0, 588, 60, 20),
                StringValue     = "Size:",
                Font            = SparkleUI.BoldFont
            };

            this.size_label_value = new NSTextField () {
                Alignment       = NSTextAlignment.Left,
                BackgroundColor = NSColor.WindowBackground,
                Bordered        = false,
                Editable        = false,
                Frame           = new RectangleF (60, 588, 75, 20),
                StringValue     = "…",
                Font            = SparkleUI.Font
            };

            this.history_label = new NSTextField () {
                Alignment       = NSTextAlignment.Right,
                BackgroundColor = NSColor.WindowBackground,
                Bordered        = false,
                Editable        = false,
                Frame           = new RectangleF (130, 588, 60, 20),
                StringValue     = "History:",
                Font            = SparkleUI.BoldFont
            };

            this.history_label_value = new NSTextField () {
                Alignment       = NSTextAlignment.Left,
                BackgroundColor = NSColor.WindowBackground,
                Bordered        = false,
                Editable        = false,
                Frame           = new RectangleF (190, 588, 75, 20),
                StringValue     = "…",
                Font            = SparkleUI.Font
            };

            ContentView.AddSubview (this.size_label);
            ContentView.AddSubview (this.size_label_value);
            ContentView.AddSubview (this.history_label);
            ContentView.AddSubview (this.history_label_value);
            ContentView.AddSubview (this.separator);

            this.progress_indicator = new NSProgressIndicator () {
                Style = NSProgressIndicatorStyle.Spinning,
                Frame = new RectangleF (this.web_view.Frame.Width / 2 - 10, this.web_view.Frame.Height / 2 + 10, 20, 20)
            };

            this.progress_indicator.StartAnimation (this);
            ContentView.AddSubview (this.progress_indicator);

            UpdateContent (null);
            UpdateChooser (null);
            OrderFrontRegardless ();

            Program.UI.UpdateDockIconVisibility ();

            // Hook up the controller events
            Controller.UpdateChooserEvent += delegate (string [] folders) {
                InvokeOnMainThread (delegate {
                    UpdateChooser (folders);
                });
            };

            Controller.UpdateContentEvent += delegate (string html) {
                InvokeOnMainThread (delegate {
                    UpdateContent (html);
                });
            };

            Controller.ContentLoadingEvent += delegate {
                InvokeOnMainThread (delegate {
                    if (this.web_view.Superview == ContentView)
                        this.web_view.RemoveFromSuperview ();

                    ContentView.AddSubview (this.progress_indicator);
                });
            };

            Controller.UpdateSizeInfoEvent += delegate (string size, string history_size) {
                InvokeOnMainThread (delegate {
                    this.size_label_value.StringValue = size;
                    this.history_label_value.StringValue = history_size;
                });
            };
        }
예제 #9
0
        public SparkleEventLog() : base()
        {
            using (var a = new NSAutoreleasePool())
            {
                Title    = "Recent Changes";
                Delegate = new SparkleEventsDelegate();
                // TODO: Make window resizable

                int   width  = 480;
                int   height = 640;
                float x      = (float)(NSScreen.MainScreen.Frame.Width * 0.61);
                float y      = (float)(NSScreen.MainScreen.Frame.Height * 0.5 - (height * 0.5));

                SetFrame(new RectangleF(x, y, width, height), true);


                StyleMask = (NSWindowStyle.Closable |
                             NSWindowStyle.Miniaturizable |
                             NSWindowStyle.Titled);

                MaxSize     = new SizeF(480, 640);
                MinSize     = new SizeF(480, 640);
                HasShadow   = true;
                BackingType = NSBackingStore.Buffered;


                this.web_view = new WebView(new RectangleF(0, 0, 481, 579), "", "")
                {
                    PolicyDelegate = new SparkleWebPolicyDelegate()
                };


                this.hidden_close_button = new NSButton()
                {
                    Frame = new RectangleF(0, 0, 0, 0),
                    KeyEquivalentModifierMask = NSEventModifierMask.CommandKeyMask,
                    KeyEquivalent             = "w"
                };

                this.hidden_close_button.Activated += delegate {
                    Controller.WindowClosed();
                };


                this.size_label = new NSTextField()
                {
                    Alignment       = NSTextAlignment.Right,
                    BackgroundColor = NSColor.WindowBackground,
                    Bordered        = false,
                    Editable        = false,
                    Frame           = new RectangleF(0, 588, 60, 20),
                    StringValue     = "Size:",
                    Font            = SparkleUI.BoldFont
                };

                this.size_label_value = new NSTextField()
                {
                    Alignment       = NSTextAlignment.Left,
                    BackgroundColor = NSColor.WindowBackground,
                    Bordered        = false,
                    Editable        = false,
                    Frame           = new RectangleF(60, 588, 75, 20),
                    StringValue     = "…",
                    Font            = SparkleUI.Font
                };


                this.history_label = new NSTextField()
                {
                    Alignment       = NSTextAlignment.Right,
                    BackgroundColor = NSColor.WindowBackground,
                    Bordered        = false,
                    Editable        = false,
                    Frame           = new RectangleF(130, 588, 60, 20),
                    StringValue     = "History:",
                    Font            = SparkleUI.BoldFont
                };

                this.history_label_value = new NSTextField()
                {
                    Alignment       = NSTextAlignment.Left,
                    BackgroundColor = NSColor.WindowBackground,
                    Bordered        = false,
                    Editable        = false,
                    Frame           = new RectangleF(190, 588, 75, 20),
                    StringValue     = "…",
                    Font            = SparkleUI.Font
                };


                this.separator = new NSBox(new RectangleF(0, 579, 480, 1))
                {
                    BorderColor = NSColor.LightGray,
                    BoxType     = NSBoxType.NSBoxCustom
                };


                this.background = new NSBox(new RectangleF(0, -1, 481, 581))
                {
                    FillColor = NSColor.White,
                    BoxType   = NSBoxType.NSBoxCustom
                };


                this.progress_indicator = new NSProgressIndicator()
                {
                    Style = NSProgressIndicatorStyle.Spinning,
                    Frame = new RectangleF(this.web_view.Frame.Width / 2 - 10,
                                           this.web_view.Frame.Height / 2 + 10, 20, 20)
                };

                this.progress_indicator.StartAnimation(this);


                ContentView.AddSubview(this.size_label);
                ContentView.AddSubview(this.size_label_value);
                ContentView.AddSubview(this.history_label);
                ContentView.AddSubview(this.history_label_value);
                ContentView.AddSubview(this.separator);
                ContentView.AddSubview(this.progress_indicator);
                ContentView.AddSubview(this.background);
                ContentView.AddSubview(this.hidden_close_button);


                (this.web_view.PolicyDelegate as SparkleWebPolicyDelegate).LinkClicked += delegate(string href) {
                    Controller.LinkClicked(href);
                };
            }


            // Hook up the controller events
            Controller.HideWindowEvent += delegate {
                using (var a = new NSAutoreleasePool())
                {
                    InvokeOnMainThread(delegate {
                        PerformClose(this);

                        if (this.web_view.Superview == ContentView)
                        {
                            this.web_view.RemoveFromSuperview();
                        }
                    });
                }
            };

            Controller.ShowWindowEvent += delegate {
                using (var a = new NSAutoreleasePool())
                {
                    InvokeOnMainThread(delegate {
                        OrderFrontRegardless();
                    });
                }
            };

            Controller.UpdateChooserEvent += delegate(string [] folders) {
                using (var a = new NSAutoreleasePool())
                {
                    InvokeOnMainThread(delegate {
                        UpdateChooser(folders);
                    });
                }
            };

            Controller.UpdateContentEvent += delegate(string html) {
                using (var a = new NSAutoreleasePool())
                {
                    InvokeOnMainThread(delegate {
                        UpdateContent(html);
                    });
                }
            };

            Controller.ContentLoadingEvent += delegate {
                using (var a = new NSAutoreleasePool())
                {
                    InvokeOnMainThread(delegate {
                        if (this.web_view.Superview == ContentView)
                        {
                            this.web_view.RemoveFromSuperview();
                        }

                        ContentView.AddSubview(this.progress_indicator);
                    });
                }
            };

            Controller.UpdateSizeInfoEvent += delegate(string size, string history_size) {
                using (var a = new NSAutoreleasePool())
                {
                    InvokeOnMainThread(delegate {
                        this.size_label_value.StringValue    = size;
                        this.history_label_value.StringValue = history_size;
                    });
                }
            };
        }
예제 #10
0
        public EventLog()
        {
            Title    = "Recent Changes";
            Delegate = new SparkleEventsDelegate();

            int min_width  = 480;
            int min_height = 640;
            int height     = (int)(NSScreen.MainScreen.Frame.Height * 0.85);

            float x = (float)(NSScreen.MainScreen.Frame.Width * 0.61);
            float y = (float)(NSScreen.MainScreen.Frame.Height * 0.5 - (height * 0.5));

            SetFrame(
                new CGRect(
                    new CGPoint(x, y),
                    new CGSize(min_width, height)),
                true);

            StyleMask = (NSWindowStyle.Closable | NSWindowStyle.Miniaturizable |
                         NSWindowStyle.Titled | NSWindowStyle.Resizable);

            MinSize        = new CGSize(min_width, min_height);
            HasShadow      = true;
            IsOpaque       = false;
            BackingType    = NSBackingStore.Buffered;
            TitlebarHeight = (float)(Frame.Height - ContentView.Frame.Height);
            Level          = NSWindowLevel.Floating;


            this.web_view = new WebView(new CGRect(0, 0, 481, 579), "", "")
            {
                Frame = new CGRect(new CGPoint(0, 0),
                                   new CGSize(ContentView.Frame.Width, ContentView.Frame.Height - 39))
            };

            this.web_view.Preferences.PlugInsEnabled = false;

            this.cover = new NSBox()
            {
                Frame = new CGRect(
                    new CGPoint(-1, -1),
                    new CGSize(Frame.Width + 2, this.web_view.Frame.Height + 1)),
                FillColor        = NSColor.White,
                BorderType       = NSBorderType.NoBorder,
                BoxType          = NSBoxType.NSBoxCustom,
                AutoresizingMask = NSViewResizingMask.WidthSizable | NSViewResizingMask.HeightSizable
            };

            this.hidden_close_button = new NSButton()
            {
                KeyEquivalentModifierMask = NSEventModifierMask.CommandKeyMask,
                KeyEquivalent             = "w"
            };

            this.hidden_close_button.Activated += delegate {
                Controller.WindowClosed();
            };


            this.size_label = new NSTextField()
            {
                Alignment       = NSTextAlignment.Right,
                BackgroundColor = NSColor.WindowBackground,
                Bordered        = false,
                Editable        = false,
                Frame           = new CGRect(
                    new CGPoint(0, ContentView.Frame.Height - 31),
                    new CGSize(60, 20)),
                StringValue      = "Size:",
                AutoresizingMask = NSViewResizingMask.MaxXMargin | NSViewResizingMask.MinYMargin
            };

            this.size_label_value = new NSTextField()
            {
                Alignment       = NSTextAlignment.Left,
                BackgroundColor = NSColor.WindowBackground,
                Bordered        = false,
                Editable        = false,
                Frame           = new CGRect(
                    new CGPoint(60, ContentView.Frame.Height - 31),
                    new CGSize(60, 20)),
                StringValue      = "…",
                Font             = NSFont.BoldSystemFontOfSize(12),
                AutoresizingMask = NSViewResizingMask.MaxXMargin | NSViewResizingMask.MinYMargin
            };

            this.history_label = new NSTextField()
            {
                Alignment       = NSTextAlignment.Right,
                BackgroundColor = NSColor.WindowBackground,
                Bordered        = false,
                Editable        = false,
                Frame           = new CGRect(
                    new CGPoint(130, ContentView.Frame.Height - 31),
                    new CGSize(60, 20)),
                StringValue      = "History:",
                AutoresizingMask = NSViewResizingMask.MaxXMargin | NSViewResizingMask.MinYMargin
            };

            this.history_label_value = new NSTextField()
            {
                Alignment       = NSTextAlignment.Left,
                BackgroundColor = NSColor.WindowBackground,
                Bordered        = false,
                Editable        = false,
                Frame           = new CGRect(
                    new CGPoint(190, ContentView.Frame.Height - 31),
                    new CGSize(60, 20)
                    ),
                StringValue      = "…",
                Font             = NSFont.BoldSystemFontOfSize(12),
                AutoresizingMask = NSViewResizingMask.MaxXMargin | NSViewResizingMask.MinYMargin
            };

            this.popup_button = new NSPopUpButton()
            {
                Frame = new CGRect(
                    new CGPoint(ContentView.Frame.Width - 156 - 12, ContentView.Frame.Height - 33),
                    new CGSize(156, 26)),
                PullsDown        = false,
                AutoresizingMask = NSViewResizingMask.MinXMargin | NSViewResizingMask.MinYMargin
            };

            this.background = new NSBox()
            {
                Frame = new CGRect(
                    new CGPoint(-1, -1),
                    new CGSize(Frame.Width + 2, this.web_view.Frame.Height + 2)),
                FillColor        = NSColor.White,
                BorderColor      = NSColor.LightGray,
                BoxType          = NSBoxType.NSBoxCustom,
                AutoresizingMask = NSViewResizingMask.WidthSizable | NSViewResizingMask.HeightSizable
            };

            this.progress_indicator = new NSProgressIndicator()
            {
                Frame = new CGRect(
                    new CGPoint(Frame.Width / 2 - 10, this.web_view.Frame.Height / 2 + 10),
                    new CGSize(20, 20)),
                Style            = NSProgressIndicatorStyle.Spinning,
                AutoresizingMask = NSViewResizingMask.MinXMargin | NSViewResizingMask.MaxXMargin |
                                   NSViewResizingMask.MinYMargin | NSViewResizingMask.MaxYMargin
            };

            this.progress_indicator.StartAnimation(this);


            ContentView.AddSubview(this.size_label);
            ContentView.AddSubview(this.size_label_value);
            ContentView.AddSubview(this.history_label);
            ContentView.AddSubview(this.history_label_value);
            ContentView.AddSubview(this.popup_button);
            ContentView.AddSubview(this.progress_indicator);
            ContentView.AddSubview(this.background);
            ContentView.AddSubview(this.hidden_close_button);


            Controller.HideWindowEvent     += HideWindowEventDelegate;
            Controller.ShowWindowEvent     += ShowWindowEventDelegate;
            Controller.ShowSaveDialogEvent += ShowSaveDialogEventDelegate;

            Controller.UpdateChooserEvent           += UpdateChooserEventDelegate;
            Controller.UpdateChooserEnablementEvent += UpdateChooserEnablementEventDelegate;
            Controller.UpdateContentEvent           += UpdateContentEventDelegate;
            Controller.UpdateSizeInfoEvent          += UpdateSizeInfoEventDelegate;

            Controller.ContentLoadingEvent += ContentLoadingEventDelegate;
        }
예제 #11
0
        public SparkleEventLog() : base()
        {
            using (var a = new NSAutoreleasePool())
            {
                Title    = "Recent Changes";
                Delegate = new SparkleEventsDelegate();

                int   min_width  = 480;
                int   min_height = 640;
                float x          = (float)(NSScreen.MainScreen.Frame.Width * 0.61);
                float y          = (float)(NSScreen.MainScreen.Frame.Height * 0.5 - (min_height * 0.5));

                SetFrame(
                    new RectangleF(
                        new PointF(x, y),
                        new SizeF(min_width, (int)(NSScreen.MainScreen.Frame.Height * 0.85))),
                    true);

                StyleMask = (NSWindowStyle.Closable |
                             NSWindowStyle.Miniaturizable |
                             NSWindowStyle.Titled |
                             NSWindowStyle.Resizable);

                MinSize        = new SizeF(min_width, min_height);
                HasShadow      = true;
                BackingType    = NSBackingStore.Buffered;
                TitlebarHeight = Frame.Height - ContentView.Frame.Height;


                this.web_view = new WebView(new RectangleF(0, 0, 481, 579), "", "")
                {
                    Frame = new RectangleF(new PointF(0, 0),
                                           new SizeF(ContentView.Frame.Width, ContentView.Frame.Height - 39))
                };

                this.hidden_close_button = new NSButton()
                {
                    KeyEquivalentModifierMask = NSEventModifierMask.CommandKeyMask,
                    KeyEquivalent             = "w"
                };

                this.hidden_close_button.Activated += delegate {
                    Controller.WindowClosed();
                };


                this.size_label = new NSTextField()
                {
                    Alignment       = NSTextAlignment.Right,
                    BackgroundColor = NSColor.WindowBackground,
                    Bordered        = false,
                    Editable        = false,
                    Frame           = new RectangleF(
                        new PointF(0, ContentView.Frame.Height - 30),
                        new SizeF(60, 20)),
                    StringValue = "Size:",
                    Font        = SparkleUI.BoldFont
                };

                this.size_label_value = new NSTextField()
                {
                    Alignment       = NSTextAlignment.Left,
                    BackgroundColor = NSColor.WindowBackground,
                    Bordered        = false,
                    Editable        = false,
                    Frame           = new RectangleF(
                        new PointF(60, ContentView.Frame.Height - 30),
                        new SizeF(60, 20)),
                    StringValue = "…",
                    Font        = SparkleUI.Font
                };


                this.history_label = new NSTextField()
                {
                    Alignment       = NSTextAlignment.Right,
                    BackgroundColor = NSColor.WindowBackground,
                    Bordered        = false,
                    Editable        = false,
                    Frame           = new RectangleF(
                        new PointF(130, ContentView.Frame.Height - 30),
                        new SizeF(60, 20)),
                    StringValue = "History:",
                    Font        = SparkleUI.BoldFont
                };

                this.history_label_value = new NSTextField()
                {
                    Alignment       = NSTextAlignment.Left,
                    BackgroundColor = NSColor.WindowBackground,
                    Bordered        = false,
                    Editable        = false,
                    Frame           = new RectangleF(
                        new PointF(190, ContentView.Frame.Height - 30),
                        new SizeF(60, 20)
                        ),
                    StringValue = "…",
                    Font        = SparkleUI.Font
                };

                this.popup_button = new NSPopUpButton()
                {
                    Frame = new RectangleF(
                        new PointF(ContentView.Frame.Width - 156 - 12, ContentView.Frame.Height - 33),
                        new SizeF(156, 26)),
                    PullsDown = false
                };

                this.background = new NSBox()
                {
                    Frame = new RectangleF(
                        new PointF(-1, -1),
                        new SizeF(Frame.Width + 2, this.web_view.Frame.Height + 2)),
                    FillColor   = NSColor.White,
                    BorderColor = NSColor.LightGray,
                    BoxType     = NSBoxType.NSBoxCustom
                };

                this.progress_indicator = new NSProgressIndicator()
                {
                    Frame = new RectangleF(
                        new PointF(Frame.Width / 2 - 10, this.web_view.Frame.Height / 2 + 10),
                        new SizeF(20, 20)),
                    Style = NSProgressIndicatorStyle.Spinning
                };

                this.progress_indicator.StartAnimation(this);

                ContentView.AddSubview(this.size_label);
                ContentView.AddSubview(this.size_label_value);
                ContentView.AddSubview(this.history_label);
                ContentView.AddSubview(this.history_label_value);
                ContentView.AddSubview(this.popup_button);
                ContentView.AddSubview(this.progress_indicator);
                ContentView.AddSubview(this.background);
                ContentView.AddSubview(this.hidden_close_button);

                (Delegate as SparkleEventsDelegate).WindowResized += Relayout;
            }


            // Hook up the controller events
            Controller.HideWindowEvent += delegate {
                using (var a = new NSAutoreleasePool())
                {
                    InvokeOnMainThread(delegate {
                        PerformClose(this);

                        if (this.web_view.Superview == ContentView)
                        {
                            this.web_view.RemoveFromSuperview();
                        }
                    });
                }
            };

            Controller.ShowWindowEvent += delegate {
                using (var a = new NSAutoreleasePool())
                {
                    InvokeOnMainThread(delegate {
                        OrderFrontRegardless();
                    });
                }
            };

            Controller.UpdateChooserEvent += delegate(string [] folders) {
                using (var a = new NSAutoreleasePool())
                {
                    InvokeOnMainThread(delegate {
                        UpdateChooser(folders);
                    });
                }
            };

            Controller.UpdateContentEvent += delegate(string html) {
                using (var a = new NSAutoreleasePool())
                {
                    InvokeOnMainThread(delegate {
                        UpdateContent(html);
                    });
                }
            };

            Controller.ContentLoadingEvent += delegate {
                using (var a = new NSAutoreleasePool())
                {
                    InvokeOnMainThread(delegate {
                        if (this.web_view.Superview == ContentView)
                        {
                            this.web_view.RemoveFromSuperview();
                        }

                        if (this.progress_indicator.Superview != ContentView)
                        {
                            ContentView.AddSubview(this.progress_indicator);
                        }

                        this.progress_indicator.StartAnimation(this);
                    });
                }
            };

            Controller.UpdateSizeInfoEvent += delegate(string size, string history_size) {
                using (var a = new NSAutoreleasePool())
                {
                    InvokeOnMainThread(delegate {
                        this.size_label_value.StringValue    = size;
                        this.history_label_value.StringValue = history_size;
                    });
                }
            };
        }