コード例 #1
0
        public SparkleEventLog() : base("")
        {
            SetSizeRequest(480, (int)(Gdk.Screen.Default.Height * 0.8));

            int x = (int)(Gdk.Screen.Default.Width * 0.61);
            int y = (int)(Gdk.Screen.Default.Height * 0.5 - (HeightRequest * 0.5));

            Move(x, y);

            Resizable   = true;
            BorderWidth = 0;

            Title    = "Recent Changes";
            IconName = "folder-sparkleshare";

            DeleteEvent += delegate(object o, DeleteEventArgs args) {
                Controller.WindowClosed();
                args.RetVal = true;
            };

            KeyPressEvent += delegate(object o, KeyPressEventArgs args) {
                if (args.Event.Key == Gdk.Key.Escape ||
                    (args.Event.State == Gdk.ModifierType.ControlMask && args.Event.Key == Gdk.Key.w))
                {
                    Controller.WindowClosed();
                }
            };

            this.size_label = new Label()
            {
                Markup = "<b>Size:</b> …",
                Xalign = 0
            };

            this.history_label = new Label()
            {
                Markup = "<b>History:</b> …",
                Xalign = 0
            };

            HBox layout_sizes = new HBox(false, 12);

            layout_sizes.Add(this.size_label);
            layout_sizes.Add(this.history_label);

            VBox layout_vertical = new VBox(false, 0);

            this.spinner         = new SparkleSpinner(22);
            this.content_wrapper = new EventBox();
            this.scrolled_window = new ScrolledWindow();

            Gdk.Color white = new Gdk.Color();
            Gdk.Color.Parse("white", ref white);

            this.content_wrapper.ModifyBg(StateType.Normal, white);

            this.web_view = new WebView()
            {
                Editable = false
            };


            this.web_view.NavigationRequested += WebViewNavigationRequested;

            this.scrolled_window.Add(this.web_view);
            this.content_wrapper.Add(this.spinner);

            this.spinner.Start();

            this.layout_horizontal = new HBox(true, 0);
            this.layout_horizontal.PackStart(layout_sizes, true, true, 12);

            layout_vertical.PackStart(this.layout_horizontal, false, false, 0);
            layout_vertical.PackStart(this.content_wrapper, true, true, 0);

            Add(layout_vertical);


            Controller.HideWindowEvent += delegate {
                Application.Invoke(delegate {
                    HideAll();

                    if (this.content_wrapper.Child != null)
                    {
                        this.content_wrapper.Remove(this.content_wrapper.Child);
                    }
                });
            };

            Controller.ShowWindowEvent += delegate {
                Application.Invoke(delegate {
                    ShowAll();
                    Present();
                });
            };

            Controller.ShowSaveDialogEvent += delegate(string file_name, string target_folder_path) {
                Application.Invoke(delegate {
                    FileChooserDialog dialog = new FileChooserDialog("Restore from History",
                                                                     this, FileChooserAction.Save, "Cancel", ResponseType.Cancel, "Save", ResponseType.Ok);

                    dialog.CurrentName             = file_name;
                    dialog.DoOverwriteConfirmation = true;
                    dialog.SetCurrentFolder(target_folder_path);

                    if (dialog.Run() == (int)ResponseType.Ok)
                    {
                        Controller.SaveDialogCompleted(dialog.Filename);
                    }
                    else
                    {
                        Controller.SaveDialogCancelled();
                    }

                    dialog.Destroy();
                });
            };

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

            Controller.UpdateChooserEnablementEvent += delegate(bool enabled) {
                Application.Invoke(delegate {
                    this.combo_box.Sensitive = enabled;
                });
            };

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

            Controller.ContentLoadingEvent += delegate {
                Application.Invoke(delegate {
                    if (this.content_wrapper.Child != null)
                    {
                        this.content_wrapper.Remove(this.content_wrapper.Child);
                    }

                    this.content_wrapper.Add(this.spinner);
                    this.spinner.Start();
                    this.content_wrapper.ShowAll();
                });
            };

            Controller.UpdateSizeInfoEvent += delegate(string size, string history_size) {
                Application.Invoke(delegate {
                    this.size_label.Markup    = "<b>Size:</b> " + size;
                    this.history_label.Markup = "<b>History:</b> " + history_size;

                    this.size_label.ShowAll();
                    this.history_label.ShowAll();
                });
            };
        }
コード例 #2
0
        public SparkleEventLog() : base("Recent Changes")
        {
            SetWmclass("SparkleShare", "SparkleShare");

            Gdk.Rectangle monitor_0_rect = Gdk.Screen.Default.GetMonitorGeometry(0);
            SetSizeRequest(480, (int)(monitor_0_rect.Height * 0.8));

            IconName   = "sparkleshare";
            this.pos_x = (int)(monitor_0_rect.Width * 0.61);
            this.pos_y = (int)(monitor_0_rect.Height * 0.5 - (HeightRequest * 0.5));

            this.size_label = new Label()
            {
                Xalign = 0, Markup = "<b>Size:</b> …"
            };
            this.history_label = new Label()
            {
                Xalign = 0, Markup = "<b>History:</b> …"
            };

            this.size_label.SetSizeRequest(100, 24);

            HBox layout_sizes = new HBox(false, 0);

            layout_sizes.PackStart(this.size_label, false, false, 12);
            layout_sizes.PackStart(this.history_label, false, false, 0);

            VBox layout_vertical = new VBox(false, 0);

            this.spinner         = new Spinner();
            this.spinner_wrapper = new VBox();
            this.content_wrapper = new EventBox();
            this.scrolled_window = new ScrolledWindow();

            this.content_wrapper.OverrideBackgroundColor(StateFlags.Normal,
                                                         new Gdk.RGBA()
            {
                Red = 1, Green = 1, Blue = 1, Alpha = 1
            });

            this.web_view = new WebView()
            {
                Editable = false
            };
            this.web_view.NavigationRequested += WebViewNavigationRequested;

            this.scrolled_window.Add(this.web_view);

            this.spinner_wrapper = new VBox(false, 0);
            this.spinner_wrapper.PackStart(new Label(""), true, true, 0);
            this.spinner_wrapper.PackStart(this.spinner, false, false, 0);
            this.spinner_wrapper.PackStart(new Label(""), true, true, 0);
            this.spinner.SetSizeRequest(24, 24);
            this.spinner.Start();

            this.content_wrapper.Add(this.spinner_wrapper);

            this.layout_horizontal = new HBox(false, 0);
            this.layout_horizontal.PackStart(layout_sizes, true, true, 12);

            layout_vertical.PackStart(this.layout_horizontal, false, false, 0);
            layout_vertical.PackStart(new HSeparator(), false, false, 0);
            layout_vertical.PackStart(this.content_wrapper, true, true, 0);

            Add(layout_vertical);


            Controller.HideWindowEvent += delegate {
                Application.Invoke(delegate {
                    Hide();

                    if (this.content_wrapper.Child != null)
                    {
                        this.content_wrapper.Remove(this.content_wrapper.Child);
                    }
                });
            };

            Controller.ShowWindowEvent += delegate {
                Application.Invoke(delegate {
                    Move(this.pos_x, this.pos_y);
                    ShowAll();
                    Present();
                });
            };

            Controller.ShowSaveDialogEvent += delegate(string file_name, string target_folder_path) {
                Application.Invoke(delegate {
                    FileChooserDialog dialog = new FileChooserDialog("Restore from History", this,
                                                                     FileChooserAction.Save, "Cancel", ResponseType.Cancel, "Save", ResponseType.Ok);

                    dialog.CurrentName             = file_name;
                    dialog.DoOverwriteConfirmation = true;
                    dialog.SetCurrentFolder(target_folder_path);

                    if (dialog.Run() == (int)ResponseType.Ok)
                    {
                        Controller.SaveDialogCompleted(dialog.Filename);
                    }
                    else
                    {
                        Controller.SaveDialogCancelled();
                    }

                    dialog.Destroy();
                });
            };

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

            Controller.UpdateChooserEnablementEvent += delegate(bool enabled) {
                Application.Invoke(delegate { this.combo_box.Sensitive = enabled; });
            };

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

            Controller.ContentLoadingEvent += delegate {
                Application.Invoke(delegate {
                    if (this.content_wrapper.Child != null)
                    {
                        this.content_wrapper.Remove(this.content_wrapper.Child);
                    }

                    this.content_wrapper.Add(this.spinner_wrapper);
                    this.spinner.Start();
                });
            };

            Controller.UpdateSizeInfoEvent += delegate(string size, string history_size) {
                Application.Invoke(delegate {
                    this.size_label.Markup    = "<b>Size</b>  " + size;
                    this.history_label.Markup = "<b>History</b>  " + history_size;
                });
            };

            DeleteEvent += delegate(object o, DeleteEventArgs args) {
                Controller.WindowClosed();
                args.RetVal = true;
            };

            KeyPressEvent += delegate(object o, KeyPressEventArgs args) {
                if (args.Event.Key == Gdk.Key.Escape ||
                    (args.Event.State == Gdk.ModifierType.ControlMask && args.Event.Key == Gdk.Key.w))
                {
                    Controller.WindowClosed();
                }
            };
        }
コード例 #3
0
 private void Close(object sender, CancelEventArgs args)
 {
     Controller.WindowClosed();
     args.Cancel = true;
 }
コード例 #4
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();
                    }
                });
            };
        }
コード例 #5
0
ファイル: SparkleEventLog.cs プロジェクト: lefty01/CmisSync
        public SparkleEventLog() : base("")
        {
            SetSizeRequest(480, (int)(Gdk.Screen.Default.Height * 0.8));

            int x = (int)(Gdk.Screen.Default.Width * 0.61);
            int y = (int)(Gdk.Screen.Default.Height * 0.5 - (HeightRequest * 0.5));

            Move(x, y);

            Resizable   = true;
            BorderWidth = 0;

            Title    = "Recent Changes";
            IconName = "folder-sparkleshare";

            DeleteEvent += delegate(object o, DeleteEventArgs args) {
                Controller.WindowClosed();
                args.RetVal = true;
            };

            KeyPressEvent += delegate(object o, KeyPressEventArgs args) {
                if (args.Event.Key == Gdk.Key.Escape ||
                    (args.Event.State == Gdk.ModifierType.ControlMask) &&
                    args.Event.Key == Gdk.Key.w)
                {
                    Controller.WindowClosed();
                }
            };

            this.size_label = new Label()
            {
                Markup = "<b>Size:</b> …",
                Xalign = 0
            };

            this.history_label = new Label()
            {
                Markup = "<b>History:</b> …",
                Xalign = 0
            };

            HBox layout_sizes = new HBox(false, 12);

            layout_sizes.Add(this.size_label);
            layout_sizes.Add(this.history_label);

            VBox layout_vertical = new VBox(false, 0);

            this.spinner         = new SparkleSpinner(22);
            this.content_wrapper = new EventBox();
            this.scrolled_window = new ScrolledWindow();

            Gdk.Color white = new Gdk.Color();
            Gdk.Color.Parse("white", ref white);

            this.content_wrapper.ModifyBg(StateType.Normal, white);

            this.web_view = new WebView()
            {
                Editable = false
            };


            this.web_view.NavigationRequested += WebViewNavigationRequested;

            this.scrolled_window.Add(this.web_view);
            this.content_wrapper.Add(this.spinner);

            this.spinner.Start();

            this.layout_horizontal = new HBox(true, 0);
            this.layout_horizontal.PackStart(layout_sizes, true, true, 12);

            layout_vertical.PackStart(this.layout_horizontal, false, false, 0);
            layout_vertical.PackStart(this.content_wrapper, true, true, 0);

            Add(layout_vertical);


            Controller.HideWindowEvent += delegate {
                Application.Invoke(delegate {
                    HideAll();

                    if (this.content_wrapper.Child != null)
                    {
                        this.content_wrapper.Remove(this.content_wrapper.Child);
                    }
                });
            };

            Controller.ShowWindowEvent += delegate {
                Application.Invoke(delegate {
                    ShowAll();
                    Present();
                });
            };

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

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

            Controller.ContentLoadingEvent += delegate {
                Application.Invoke(delegate {
                    if (this.content_wrapper.Child != null)
                    {
                        this.content_wrapper.Remove(this.content_wrapper.Child);
                    }

                    this.content_wrapper.Add(this.spinner);
                    this.spinner.Start();
                    this.content_wrapper.ShowAll();
                });
            };

            Controller.UpdateSizeInfoEvent += delegate(string size, string history_size) {
                Application.Invoke(delegate {
                    this.size_label.Markup    = "<b>Size:</b> " + size;
                    this.history_label.Markup = "<b>History:</b> " + history_size;

                    this.size_label.ShowAll();
                    this.history_label.ShowAll();
                });
            };
        }
コード例 #6
0
 private void OnClosing(object sender, CancelEventArgs cancel_event_args)
 {
     Controller.WindowClosed();
     cancel_event_args.Cancel = true;
 }
コード例 #7
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;
                    });
                }
            };
        }
コード例 #8
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;
                    });
                }
            };
        }