Exemplo n.º 1
0
        private void CreateEventLog()
        {
            OpenFolderButton = new NSButton(new RectangleF(16, 12, 120, 32))
            {
                Title      = "Open Folder",
                BezelStyle = NSBezelStyle.Rounded,
                Font       = SparkleUI.Font
            };

            OpenFolderButton.Activated += delegate {
                SparkleShare.Controller.OpenSparkleShareFolder(LocalPath);
            };

            ContentView.AddSubview(OpenFolderButton);


            CloseButton = new NSButton(new RectangleF(480 - 120 - 16, 12, 120, 32))
            {
                Title      = "Close",
                BezelStyle = NSBezelStyle.Rounded,
                Font       = SparkleUI.Font
            };

            CloseButton.Activated += delegate {
                InvokeOnMainThread(delegate {
                    PerformClose(this);
                });
            };

            ContentView.AddSubview(CloseButton);


            string name = Path.GetFileName(LocalPath);

            Title = String.Format("Events in ‘{0}’", name);

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

            ContentView.AddSubview(Separator);


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

            ProgressIndicator.StartAnimation(this);

            WebView = new WebView(new RectangleF(0, 59, 480, 559), "", "")
            {
                PolicyDelegate = new SparkleWebPolicyDelegate()
            };

            Update();
        }
Exemplo n.º 2
0
        public override void AwakeFromNib()
        {
            base.AwakeFromNib ();

            this.Window.Title = "Lock Game Level Generator";

            System.Drawing.RectangleF lockGridPreviewViewRectangle = this.Window.ContentView.Bounds;
            lockGridPreviewViewRectangle.Height -= 200;
            LockGridPreviewView = new NSBox (lockGridPreviewViewRectangle);
            LockGridPreviewView.BorderColor = NSColor.Gray;
            LockGridPreviewView.Title = "";

            DifficultyStepper.MinValue = 0.0f;
            DifficultyStepper.MaxValue = 1.0f;
            DifficultyStepper.Increment = 0.05f;
            DifficultyStepper.FloatValue = DifficultyTextField.FloatValue = 0.5f;

            DifficultyStepper.Activated += (object sender, EventArgs e) => {
                DifficultyTextField.FloatValue = DifficultyStepper.FloatValue;
            };

            GenerateButton.Activated += (object sender, EventArgs e) => {
                GenerateLockGrid ();
            };

            SaveButton.Activated += (object sender, EventArgs e) => {
                SaveLockGrid();
            };
        }
Exemplo n.º 3
0
 public MacFlyoutMenu(NSButtonPlus button, NSGridView menu, NSBox menuBox, NSBox buttonBar, FlyoutAttachment attachment, float pointSize, bool fixedWidth, CGSize padding,
                      NSColor nsMainButtonText, NSColor nsMainButtonDeselected, NSColor nsMainButtonSelected, NSColor nsMenuButtonText, NSColor nsMenuButtonDeselected, NSColor nsMenuButtonSelected)
     : base(button, nsMainButtonText, nsMainButtonDeselected, nsMainButtonSelected)
 {
     this.menu                   = menu;
     this.namedControls          = new Dictionary <string, KButton>();
     this.menu.RowSpacing        = 1;
     this.menu.ColumnSpacing     = 6;
     this.menuBox                = menuBox;
     this.menuBox.BorderWidth    = 1; // does not affect the origin
     this.menuBox.CornerRadius   = 0;
     this.menuBox.BorderColor    = NSColor.TertiaryLabelColor;
     this.buttonBar              = buttonBar;
     this.autoClose              = false;
     this.pointSize              = pointSize;
     this.fixedWidth             = fixedWidth;
     this.padding                = padding;
     this.attachment             = attachment;
     this.nsMenuButtonText       = nsMenuButtonText;
     this.nsMenuButtonDeselected = nsMenuButtonDeselected;
     this.nsMenuButtonSelected   = nsMenuButtonSelected;
     menuBox.FillColor           = nsMenuButtonDeselected;
     menuBox.Hidden              = true;
     MacControls.allMacFlyoutMenus.Add(this);
 }
Exemplo n.º 4
0
        public ServerSelectionButtonBase() : base()
        {
            const int constButtonHeight = 61;

            Bordered = false;
            Frame    = new CGRect(0, 0, 320, constButtonHeight);

            // horizontal line at the buttom
            __HorisontalLine             = new NSBox(new CGRect(new CGPoint(0, constButtonHeight - 1), new CGSize(320, 1)));
            __HorisontalLine.BorderType  = NSBorderType.LineBorder;
            __HorisontalLine.BorderWidth = 1;
            __HorisontalLine.BoxType     = NSBoxType.NSBoxSeparator;
            AddSubview(__HorisontalLine);

            // ============================ ITEMS FOR CONFIG MODE
            NSImage cfgImg = NSImage.ImageNamed("iconPreferences");

            __ConfigButton = new NSButton();
            __ConfigButton.SetButtonType(NSButtonType.MomentaryPushIn);
            __ConfigButton.Bordered      = false;
            __ConfigButton.ImageScaling  = NSImageScale.None;
            __ConfigButton.ImagePosition = NSCellImagePosition.ImageOnly;
            __ConfigButton.BezelStyle    = NSBezelStyle.SmallSquare;
            __ConfigButton.Image         = cfgImg;
            __ConfigButton.Frame         = new CGRect(320 - 50, (constButtonHeight - cfgImg.Size.Height) / 2, cfgImg.Size.Width, cfgImg.Size.Height);
            __ConfigButton.Activated    += (object sender, System.EventArgs e) =>
            {
                OnConfigButtonPressed(this, e);
            };
            AddSubview(__ConfigButton);
            __ConfigButton.Hidden = true;
        }
Exemplo n.º 5
0
        protected override IView OnConvertToView(FigmaNode currentNode, ProcessedNode parentNode, FigmaRendererService rendererService)
        {
            var frame = (FigmaFrame)currentNode;
            var box   = new NSBox();

            currentNode.TryGetNativeControlType(out NativeControlType controlType);

            if (controlType == NativeControlType.Separator)
            {
                box.BoxType = NSBoxType.NSBoxSeparator;
            }

            if (controlType == NativeControlType.BoxCustom)
            {
                box.BoxType     = NSBoxType.NSBoxCustom;
                box.BorderWidth = 0;

                FigmaVectorEntity rectangle = frame.children
                                              .OfType <FigmaVectorEntity>()
                                              .FirstOrDefault();

                foreach (var styleMap in rectangle?.styles)
                {
                    if (rendererService.FileProvider.TryGetStyle(styleMap.Value, out FigmaStyle style))
                    {
                        if (styleMap.Key == "fill")
                        {
                            box.FillColor = CocoaHelpers.GetNSColor(style.name);
                        }

                        if (styleMap.Key == "stroke")
                        {
                            box.BorderColor = CocoaHelpers.GetNSColor(style.name);
                            box.BorderWidth = rectangle.strokeWeight;
                        }
                    }
                }
            }

            if (controlType == NativeControlType.Box)
            {
                FigmaText text = frame.children
                                 .OfType <FigmaText>()
                                 .FirstOrDefault(s => (s.name == ComponentString.TITLE && s.visible));

                if (text != null)
                {
                    box.Title = text.characters;
                }
                else
                {
                    box.Title = "";
                }
            }

            return(new View(box));
        }
Exemplo n.º 6
0
        public NSView CreateLine()
        {
            var line = new NSBox();

            line.BoxType = NSBoxType.NSBoxSeparator;
            line.Frame   = new CGRect(0.0, 20.0, 300.0, 0.0);

            return(line);

            //add view to StackView
            //stackView.AddView(line, NSStackViewGravity.Top);
        }
Exemplo n.º 7
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
            var            gradientLayer = new CAGradientLayer();
            List <CGColor> colors        = new List <CGColor>();

            colors.Add(OxyColors.GreenYellow.ToCGColor());
            colors.Add(OxyColors.LightSkyBlue.ToCGColor());
            gradientLayer.Colors     = colors.ToArray();
            gradientLayer.StartPoint = new CGPoint(.0, 1.0);
            gradientLayer.EndPoint   = new CGPoint(.0, .0);

            IntervalCell.StringValue = "10.8\n0.7";
            IntervalCell.Bordered    = true;
            IntervalCell.Font        = NSFont.FromFontName("Helvetica Neue", 11);

            gradientLayer.Frame = new CGRect(new CGPoint(0, 0),
                                             IntervalCell.FittingSize);
            IntervalCellStack.SetFrameSize(IntervalCell.FittingSize);
            IntervalCellStack.AutoresizesSubviews = true;
            IntervalCellStack.WantsLayer          = true;
            IntervalCellStack.Layer.AddSublayer(gradientLayer);

            var exprView = new NSTextField
            {
                Alignment       = NSTextAlignment.Center,
                Selectable      = false,
                Editable        = false,
                DrawsBackground = false,
                Bordered        = false,
                LineBreakMode   = NSLineBreakMode.Clipping,
                Font            = NSFont.FromFontName("Helvetica Neue", 11)
            };

            exprView.StringValue = "12";
            exprView.RotateByAngle(90);

            exprView.SetFrameOrigin(new CGPoint(167, 76));
            exprView.SetFrameSize(new CGSize(13, 28));

            var line = new NSBox
            {
                BoxType = NSBoxType.NSBoxSeparator
            };

            line.SetFrameSize(new CGSize(2, 23));
            line.SetFrameOrigin(new CGPoint(163, 79));

            View.AddSubview(exprView);
            View.AddSubview(line);
        }
Exemplo n.º 8
0
        public void AddSeparator()
        {
            NSBox separator = new NSBox();

            separator.BoxType     = NSBoxType.NSBoxCustom;
            separator.BorderType  = NSBorderType.LineBorder;
            separator.BorderWidth = 1;
            separator.SetFrameSize(new CGSize(2, 2));
            separator.FillColor   = MacControls.nsMainButtonDeselected;
            separator.BorderColor = MacControls.nsMainButtonDeselected;
            this.menu.AddRow(new NSView[1] {
                separator
            });
            separator.LeftAnchor.ConstraintEqualToAnchor(this.menu.LeftAnchor).Active   = true;
            separator.RightAnchor.ConstraintEqualToAnchor(this.menu.RightAnchor).Active = true;
            this.menu.SetFrameOrigin(new CGPoint(0, 0)); // w.r.t. the menuBox
        }
        public BorderedWindow(CGRect frame, NSColor borderColor, NSColor fillColor, NSBorderType borderType = NSBorderType.LineBorder, float borderWidth = 3) : base(frame, NSWindowStyle.Borderless, NSBackingStore.Buffered, false)
        {
            IsOpaque           = false;
            ShowsToolbarButton = false;
            IgnoresMouseEvents = true;
            box = new NSBox()
            {
                BoxType = NSBoxType.NSBoxCustom
            };
            ContentView = box;

            FillColor   = fillColor;
            BorderWidth = borderWidth;
            BorderColor = borderColor;
            BorderType  = borderType;
            Visible     = false;
        }
Exemplo n.º 10
0
        public virtual ModalFontPanelAccessoryView Initialize(NSFontPanel panel, NSObject target)
        {
            var width = panel.Frame.Size.Width;

            line             = new NSBox();
            line.Title       = String.Empty;
            line.BoxType     = NSBoxType.NSBoxSeparator;
            line.BorderColor = NSColor.DarkGray;
            AddSubview(line);

            cancelButton        = new NSButton();
            cancelButton.Title  = Strings.CancelButtonTitle;
            cancelButton.Action = new Selector("cancel:");
            cancelButton.SetButtonType(NSButtonType.MomentaryPushIn);
            cancelButton.BezelStyle = NSBezelStyle.Rounded;
            cancelButton.Target     = target;
            AddSubview(cancelButton);

            chooseButton        = new NSButton();
            chooseButton.Title  = Strings.ChooseButtonTitle;
            chooseButton.Action = new Selector("choose:");
            chooseButton.SetButtonType(NSButtonType.MomentaryPushIn);
            chooseButton.BezelStyle = NSBezelStyle.Rounded;
            chooseButton.Target     = target;
            AddSubview(chooseButton);

            systemFontButton        = new NSButton();
            systemFontButton.Title  = Strings.SystemFontButtonTitle;
            systemFontButton.Action = new Selector("systemFont:");
            systemFontButton.SetButtonType(NSButtonType.MomentaryPushIn);
            systemFontButton.BezelStyle = NSBezelStyle.Rounded;
            systemFontButton.Target     = target;
            AddSubview(systemFontButton);

            var padding = new CGSize(10, 10);

            chooseButton.SizeToFit();
            var height = chooseButton.Frame.Height + padding.Height + padding.Height;

            SetFrameSize(new CGSize(panel.Frame.Size.Width, height));
            return(this);
        }
Exemplo n.º 11
0
        private void CreateEventLog()
        {
            OpenFolderButton = new NSButton (new RectangleF (16, 12, 120, 32)) {
                Title = "Open Folder",
                BezelStyle = NSBezelStyle.Rounded   ,
                Font = SparkleUI.Font
            };

                OpenFolderButton.Activated += delegate {
                    SparkleShare.Controller.OpenSparkleShareFolder (LocalPath);
                };

            ContentView.AddSubview (OpenFolderButton);

            CloseButton = new NSButton (new RectangleF (480 - 120 - 16, 12, 120, 32)) {
                Title = "Close",
                BezelStyle = NSBezelStyle.Rounded,
                Font = SparkleUI.Font
            };

                CloseButton.Activated += delegate {
                    InvokeOnMainThread (delegate {
                        PerformClose (this);
                    });
                };

            ContentView.AddSubview (CloseButton);

            string name = Path.GetFileName (LocalPath);
            Title = String.Format ("Events in ‘{0}’", name);

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

            ContentView.AddSubview (Separator);

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

            ProgressIndicator.StartAnimation (this);

            WebView = new WebView (new RectangleF (0, 59, 480, 559), "", ""){
                PolicyDelegate = new SparkleWebPolicyDelegate ()
            };

            Update ();
        }
Exemplo n.º 12
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
            this.nsForm = NSObject.FromObject(this);

            this.texter = new PlatformTexter();
            fonts       = new Dictionary <float, NSFont>();
            fontsFixed  = new Dictionary <float, NSFont>();

            // Register this Gui for platform-independent access via interface KGuiControl
            KGui.Register(this);

            // Register this Gui for platform-independent access via interface KControls
            macControls = new MacControls();                        // set up platform-specific gui controls
            KGui.Register(new KControls(macControls));              // bind actions to them (non-platform specific)

            leftPanelClicker.Activated  += (object sender, EventArgs e) => { KGui.kControls.CloseOpenMenu(); };
            rightPanelClicker.Activated += (object sender, EventArgs e) => { KGui.kControls.CloseOpenMenu(); };

            // Text Areas

            inputTextView.alwaysDisableIBeamCursor              = false; // disable only when menus are up
            outputTextView.alwaysDisableIBeamCursor             = true;
            (textInput.DocumentView as AppKit.NSTextView).Font  = GetFont(12.0F, true);
            (textOutput.DocumentView as AppKit.NSTextView).Font = GetFont(12.0F, true);

            // Device

            { NSBox x = deviceBox; NSDeviceView y = kaemikaDevice; }  // just checking: these are the Outlets from Main.storyboard through XCode

            // Score

            { NSBox x = scoreBox; NSScoreView y = kaemikaScore; }  // just checking: these are the Outlets from Main.storyboard through XCode

            // Chart

            { NSChartView x = kaemikaChart; } // just checking: this is the Outlet from Main.storyboard through XCode

            SetChartTooltip("", new CGPoint(0, 0), new CGRect(0, 0, 0, 0));

            // Legend

            { NSBox x = legendFlyoutBox; NSGridView y = legendFlyoutMenu; } // just checking: these are the Outlets from Main.storyboard through XCode

            // Saved state

            macControls.RestorePreferences(); //needs kControls initialized
            GuiRestoreInput();

            // Dark Mode Detection

            var interfaceStyle = NSUserDefaults.StandardUserDefaults.StringForKey("AppleInterfaceStyle");

            MacControls.darkMode = interfaceStyle == "Dark";
            MacControls.SwitchMode();

            NSDistributedNotificationCenter.GetDefaultCenter().
            AddObserver(this,
                        new ObjCRuntime.Selector("themeChanged:"),
                        new NSString("AppleInterfaceThemeChangedNotification"),
                        null);

            // Keyboard Events
            // https://stackoverflow.com/questions/32446978/swift-capture-keydown-from-nsviewcontroller
            // list of keycodes:
            // https://stackoverflow.com/questions/3202629/where-can-i-find-a-list-of-mac-virtual-key-codes

            // for modifier keys
            NSEvent.AddLocalMonitorForEventsMatchingMask(NSEventMask.FlagsChanged,
                                                         (NSEvent e) => { try { if (MyModifiersChanged(e))
                                                                                {
                                                                                    return(null);
                                                                                }
                                                                                else
                                                                                {
                                                                                    return(e);
                                                                                } } catch { return(e); } });
            // for normal, unmodified, keys
            //NSEvent.AddLocalMonitorForEventsMatchingMask(NSEventMask.KeyDown,
            //    (NSEvent e) => { try { if (MyKeyDown(e)) return null; else return e; } catch { return e; } });
        }
Exemplo n.º 13
0
        private void CreateEvents()
        {
            Separator = new NSBox (new RectangleF (0, 579, 480, 1)) {
                BorderColor = NSColor.LightGray,
                BoxType = NSBoxType.NSBoxCustom
            };

            ContentView.AddSubview (Separator);

            WebView = new WebView (new RectangleF (0, 0, 480, 579), "", "") {
                PolicyDelegate = new SparkleWebPolicyDelegate ()
            };

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

            ProgressIndicator.StartAnimation (this);
            Update ();
        }
Exemplo n.º 14
0
        public override void DidFinishLaunching(NSNotification notification)
        {
            // Handle CMD-Q
            NSMenu mainMenu = NSApplication.SharedApplication.MainMenu = new NSMenu("Exception marshaling");

            mainMenu.AddItem("Sub", new ObjCRuntime.Selector("sub"), "S");
            var subMenu = new NSMenu("Sub");
            var quit    = new NSMenuItem("Quit", (sender, e) => {
                NSApplication.SharedApplication.Terminate(this);
            });

            quit.Enabled                   = true;
            quit.KeyEquivalent             = "q";
            quit.KeyEquivalentModifierMask = NSEventModifierMask.CommandKeyMask;
            subMenu.AddItem(quit);
            mainMenu.AutoEnablesItems = false;
            mainMenu.SetSubmenu(subMenu, mainMenu.ItemAt(0));

            // Create main window and its UI
            window       = new NSWindow(new CGRect(0, 0, 500, 500), NSWindowStyle.Titled | NSWindowStyle.Resizable | NSWindowStyle.Closable | NSWindowStyle.Miniaturizable, NSBackingStore.Buffered, true);
            window.Title = "Exception marshaling";

            var protoCell = new NSButtonCell();

            protoCell.SetButtonType(NSButtonType.Radio);

            var cellSize      = new CGSize(300, 25);
            var boxSize       = new CGSize(300, 400);
            var managedBox    = new NSBox(new CGRect(new CGPoint(0, 0), boxSize));
            var objectiveCBox = new NSBox(new CGRect(new CGPoint(managedBox.Frame.Right, managedBox.Frame.Y), boxSize));

            var throwManagedException = new NSButton(new CGRect((boxSize.Width - 200) / 2, 0, 200, cellSize.Height));

            throwManagedException.Title = "Throw managed exception";

            var marshalManagedModeMatrix = new NSMatrix(new CGRect(0, 0, managedBox.Frame.Width, cellSize.Height * 6 + 10), NSMatrixMode.Radio, protoCell, 6, 1);

            marshalManagedModeMatrix.Cells [0].Title = "None";
            marshalManagedModeMatrix.Cells [1].Title = "Default";
            marshalManagedModeMatrix.Cells [2].Title = "Unwind native code";
            marshalManagedModeMatrix.Cells [3].Title = "Throw Objective-C exception";
            marshalManagedModeMatrix.Cells [4].Title = "Abort";
            marshalManagedModeMatrix.Cells [5].Title = "Disable";
            marshalManagedModeMatrix.CellSize        = cellSize;

            var marshalManagedMode = new NSBox(new CGRect(0, throwManagedException.Frame.Bottom + 20, marshalManagedModeMatrix.Frame.Width, marshalManagedModeMatrix.Frame.Height + cellSize.Height));

            marshalManagedMode.Title = "Marshaling mode";
            marshalManagedMode.AddSubview(marshalManagedModeMatrix);

            var threadManagedMatrix = new NSMatrix(new CGRect(0, 0, managedBox.Frame.Width, cellSize.Height * 3 + 10), NSMatrixMode.Radio, protoCell, 3, 1);

            threadManagedMatrix.Cells [0].Title = "Main thread";
            threadManagedMatrix.Cells [1].Title = "Background thread";
            threadManagedMatrix.Cells [2].Title = "Threadpool thread";
            threadManagedMatrix.CellSize        = cellSize;

            var threadManaged = new NSBox(new CGRect(new CGPoint(0, marshalManagedMode.Frame.Bottom + 20), new CGSize(threadManagedMatrix.Frame.Width, threadManagedMatrix.Frame.Height + cellSize.Height)));

            threadManaged.Title = "Thread";
            threadManaged.AddSubview(threadManagedMatrix);

            var marshalObjectiveCModeMatrix = new NSMatrix(marshalManagedModeMatrix.Frame, NSMatrixMode.Radio, protoCell, 6, 1);

            marshalObjectiveCModeMatrix.Cells [0].Title = "None";
            marshalObjectiveCModeMatrix.Cells [1].Title = "Default";
            marshalObjectiveCModeMatrix.Cells [2].Title = "Unwind managed code";
            marshalObjectiveCModeMatrix.Cells [3].Title = "Throw managed exception";
            marshalObjectiveCModeMatrix.Cells [4].Title = "Abort";
            marshalObjectiveCModeMatrix.Cells [5].Title = "Disable";
            marshalObjectiveCModeMatrix.CellSize        = cellSize;

            var marshalObjectiveCMode = new NSBox(marshalManagedMode.Frame);

            marshalObjectiveCMode.Title = "Marshaling mode";
            marshalObjectiveCMode.AddSubview(marshalObjectiveCModeMatrix);

            var threadObjectiveCMatrix = new NSMatrix(threadManagedMatrix.Frame, threadManagedMatrix.Mode, threadManagedMatrix.Prototype, threadManagedMatrix.Rows, threadManagedMatrix.Columns);

            threadObjectiveCMatrix.Cells [0].Title = "Main thread";
            threadObjectiveCMatrix.Cells [1].Title = "Background thread";
            threadObjectiveCMatrix.Cells [2].Title = "Threadpool thread";
            threadObjectiveCMatrix.CellSize        = cellSize;

            var threadObjectiveC = new NSBox(threadManaged.Frame);

            threadObjectiveC.Title = "Thread";
            threadObjectiveC.AddSubview(threadObjectiveCMatrix);

            var throwObjectiveCException = new NSButton(throwManagedException.Frame);

            throwObjectiveCException.Title = "Throw Objective-C exception";

            managedBox.Title = "Managed exception";
            managedBox.AddSubview(throwManagedException);
            managedBox.AddSubview(threadManaged);
            managedBox.AddSubview(marshalManagedMode);
            managedBox.Frame = new CGRect(managedBox.Frame.X, managedBox.Frame.Y, managedBox.Frame.Width, threadManaged.Frame.Bottom + cellSize.Height);
            //managedBox.SetBoundsSize (new CGSize (managedBox.Bounds.Width, threadManaged.Frame.Bottom));
            window.ContentView.AddSubview(managedBox);

            objectiveCBox.Title = "Objective-C exception";
            objectiveCBox.AddSubview(throwObjectiveCException);
            objectiveCBox.AddSubview(threadObjectiveC);
            objectiveCBox.AddSubview(marshalObjectiveCMode);
            objectiveCBox.Frame = new CGRect(objectiveCBox.Frame.Location, managedBox.Frame.Size);
            window.ContentView.AddSubview(objectiveCBox);

            var windowContentSize = new CGSize(managedBox.Frame.Width + objectiveCBox.Frame.Width, Math.Max(managedBox.Frame.Height, objectiveCBox.Frame.Height));

            window.SetContentSize(windowContentSize);
            window.ContentMinSize = windowContentSize;
            window.Center();
            window.MakeKeyAndOrderFront(window);

            Action setModes = () => {
                if (marshalManagedModeMatrix.SelectedRow == 0)
                {
                    Exceptions.ManagedExceptionMode = null;
                }
                else
                {
                    Exceptions.ManagedExceptionMode = (MarshalManagedExceptionMode)(int)marshalManagedModeMatrix.SelectedRow - 1;
                }
                if (marshalObjectiveCModeMatrix.SelectedRow == 0)
                {
                    Exceptions.ObjectiveCExceptionMode = null;
                }
                else
                {
                    Exceptions.ObjectiveCExceptionMode = (MarshalObjectiveCExceptionMode)(int)marshalObjectiveCModeMatrix.SelectedRow - 1;
                }
            };

            throwObjectiveCException.Activated += (sender, e) => {
                setModes();
                Exceptions.ThrowObjectiveCException((ThreadMode)(int)threadObjectiveCMatrix.SelectedRow);
            };
            throwManagedException.Activated += (sender, e) => {
                setModes();
                Exceptions.ThrowManagedException((ThreadMode)(int)threadManagedMatrix.SelectedRow);
            };
        }
Exemplo n.º 15
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 ();
                        }
                    });
                }
            };
        }
Exemplo n.º 16
0
        private void CreateNote()
        {
            this.cover = new NSBox()
            {
                Frame = new RectangleF(
                    new PointF(-1, 58),
                    new SizeF(Frame.Width + 2, this.ContentView.Frame.Height + 1)),
                FillColor   = NSColor.FromCalibratedRgba(0.77f, 0.77f, 0.75f, 1.0f),
                BorderColor = NSColor.LightGray,
                BoxType     = NSBoxType.NSBoxCustom
            };


            this.user_name_text_field = new NSTextField()
            {
                Alignment       = NSTextAlignment.Left,
                BackgroundColor = NSColor.FromCalibratedRgba(0.77f, 0.77f, 0.75f, 1.0f),
                Bordered        = false,
                Editable        = false,
                Frame           = new RectangleF(
                    new PointF(85, ContentView.Frame.Height - 41),
                    new SizeF(320, 22)),
                StringValue = Program.Controller.CurrentUser.Name,
                Font        = NSFont.FromFontName(SparkleUI.FontName + " Bold", NSFont.SystemFontSize)
            };

            this.user_email_text_field = new NSTextField()
            {
                Alignment       = NSTextAlignment.Left,
                BackgroundColor = NSColor.FromCalibratedRgba(0.77f, 0.77f, 0.75f, 1.0f),
                TextColor       = NSColor.DisabledControlText,
                Bordered        = false,
                Editable        = false,
                Frame           = new RectangleF(
                    new PointF(85, ContentView.Frame.Height - 60),
                    new SizeF(320, 20)),
                StringValue = Program.Controller.CurrentUser.Email,
            };


            this.balloon_text_field = new NSTextField()
            {
                Alignment       = NSTextAlignment.Left,
                BackgroundColor = NSColor.White,
                Bordered        = false,
                Editable        = true,
                Frame           = new RectangleF(
                    new PointF(30, ContentView.Frame.Height - 137),
                    new SizeF(418, 48))
            };

            (this.balloon_text_field.Cell as NSTextFieldCell).PlaceholderString  = "Anything to add?";
            (this.balloon_text_field.Cell as NSTextFieldCell).LineBreakMode      = NSLineBreakMode.ByWordWrapping;
            (this.balloon_text_field.Cell as NSTextFieldCell).UsesSingleLineMode = false;

            this.balloon_text_field.Cell.FocusRingType = NSFocusRingType.None;


            this.cancel_button = new NSButton()
            {
                Title      = "Cancel",
                BezelStyle = NSBezelStyle.Rounded,
                Frame      = new RectangleF(Frame.Width - 15 - 105 * 2, 12, 105, 32),
            };

            this.sync_button = new NSButton()
            {
                Title      = "Sync",
                BezelStyle = NSBezelStyle.Rounded,
                Frame      = new RectangleF(Frame.Width - 15 - 105, 12, 105, 32),
            };

            this.cancel_button.Activated += delegate { Controller.CancelClicked(); };
            this.sync_button.Activated   += delegate { Controller.SyncClicked(this.balloon_text_field.StringValue); };

            DefaultButtonCell = this.sync_button.Cell;


            if (BackingScaleFactor >= 2)
            {
                this.balloon_image = NSImage.ImageNamed("text-balloon@2x");
            }
            else
            {
                this.balloon_image = NSImage.ImageNamed("text-balloon");
            }

            this.balloon_image.Size = new SizeF(438, 72);
            this.balloon_image_view = new NSImageView()
            {
                Image = this.balloon_image,
                Frame = new RectangleF(21, ContentView.Frame.Height - 145, 438, 72)
            };


            if (!string.IsNullOrEmpty(Controller.AvatarFilePath))
            {
                this.user_image = new NSImage(Controller.AvatarFilePath);
            }
            else
            {
                this.user_image = NSImage.ImageNamed("user-icon-default");
            }

            this.user_image.Size = new SizeF(48, 48);
            this.user_image_view = new NSImageView()
            {
                Image = this.user_image,
                Frame = new RectangleF(21, ContentView.Frame.Height - 65, 48, 48)
            };

            this.user_image_view.WantsLayer          = true;
            this.user_image_view.Layer.CornerRadius  = 5.0f;
            this.user_image_view.Layer.MasksToBounds = true;


            ContentView.AddSubview(this.cover);
            ContentView.AddSubview(this.cancel_button);
            ContentView.AddSubview(this.sync_button);
            ContentView.AddSubview(this.user_name_text_field);
            ContentView.AddSubview(this.user_email_text_field);

            ContentView.AddSubview(this.user_image_view);
            ContentView.AddSubview(this.balloon_image_view);
            ContentView.AddSubview(this.balloon_text_field);

            MakeFirstResponder((NSResponder)this.balloon_text_field);
        }
Exemplo n.º 17
0
        public SparkleAbout() : base()
        {
            SetFrame(new RectangleF(0, 0, 360, 260), true);
            Center();

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

            Title = "About SparkleShare";

            MaxSize     = new SizeF(360, 260);
            MinSize     = new SizeF(360, 260);
            HasShadow   = true;
            BackingType = NSBackingStore.Buffered;

            Box = new NSBox()
            {
                FillColor = NSColor.White,
                Frame     = new RectangleF(-1, Frame.Height - 105, Frame.Width + 2, 105),
                BoxType   = NSBoxType.NSBoxCustom
            };

            HeaderTextField = new NSTextField()
            {
                StringValue     = "SparkleShare",
                Frame           = new RectangleF(22, Frame.Height - 89, 318, 48),
                BackgroundColor = NSColor.White,
                Bordered        = false,
                Editable        = false,
                Font            = NSFontManager.SharedFontManager.FontWithFamily
                                      ("Lucida Grande", NSFontTraitMask.Condensed, 0, 24)
            };

            VersionTextField = new NSTextField()
            {
                StringValue     = Defines.VERSION,
                Frame           = new RectangleF(22, Frame.Height - 94, 318, 22),
                BackgroundColor = NSColor.White,
                Bordered        = false,
                Editable        = false,
                Font            = NSFontManager.SharedFontManager.FontWithFamily
                                      ("Lucida Grande", NSFontTraitMask.Unbold, 0, 11),
                TextColor = NSColor.DisabledControlText
            };

            CreditsTextField = new NSTextField()
            {
                StringValue = @"Copyright © 2010–" + DateTime.Now.Year + " Hylke Bons and others" +
                              "\n" +
                              "\n" +
                              "SparkleShare is Free and Open Source Software. You are free to use, modify, and redistribute it " +
                              "under the GNU General Public License version 3 or later.",
                Frame           = new RectangleF(22, Frame.Height - 222, 318, 98),
                BackgroundColor = NSColor.WindowBackground,
                Bordered        = false,
                Editable        = false,
                Font            = NSFontManager.SharedFontManager.FontWithFamily
                                      ("Lucida Grande", NSFontTraitMask.Unbold, 0, 11),
            };

            WebsiteButton = new NSButton()
            {
                Frame      = new RectangleF(12, 12, 120, 32),
                Title      = "Visit Website",
                BezelStyle = NSBezelStyle.Rounded,
                Font       = SparkleUI.Font
            };

            WebsiteButton.Activated += delegate {
                NSUrl url = new NSUrl("http://www.sparkleshare.org/");
                NSWorkspace.SharedWorkspace.OpenUrl(url);
            };

            CreditsButton = new NSButton()
            {
                Frame      = new RectangleF(Frame.Width - 12 - 120, 12, 120, 32),
                Title      = "Show Credits",
                BezelStyle = NSBezelStyle.Rounded,
                Font       = SparkleUI.Font
            };

            CreditsButton.Activated += delegate {
                NSUrl url = new NSUrl("http://www.sparkleshare.org/credits/");
                NSWorkspace.SharedWorkspace.OpenUrl(url);
            };

            ContentView.AddSubview(Box);
            ContentView.AddSubview(HeaderTextField);
            ContentView.AddSubview(VersionTextField);
            ContentView.AddSubview(CreditsTextField);
            ContentView.AddSubview(CreditsButton);
            ContentView.AddSubview(WebsiteButton);

            MakeKeyAndOrderFront(this);
        }
Exemplo n.º 18
0
        private void CreateNote()
        {
            this.cover = new NSBox () {
                Frame = new RectangleF (
                    new PointF (-1, 58),
                    new SizeF (Frame.Width + 2, this.ContentView.Frame.Height + 1)),
                FillColor = NSColor.FromCalibratedRgba (0.77f, 0.77f, 0.75f, 1.0f),
                BorderColor = NSColor.LightGray,
                BoxType = NSBoxType.NSBoxCustom
            };

            this.user_name_text_field = new NSTextField () {
                Alignment       = NSTextAlignment.Left,
                BackgroundColor = NSColor.FromCalibratedRgba (0.77f, 0.77f, 0.75f, 1.0f),
                Bordered        = false,
                Editable        = false,
                Frame           = new RectangleF (
                    new PointF (85, ContentView.Frame.Height - 41),
                    new SizeF (320, 22)),
                StringValue     = SparkleShare.Controller.CurrentUser.Name,
                Font            = NSFont.FromFontName (UserInterface.FontName + " Bold", NSFont.SystemFontSize)
            };

            this.user_email_text_field = new NSTextField () {
                Alignment       = NSTextAlignment.Left,
                BackgroundColor = NSColor.FromCalibratedRgba (0.77f, 0.77f, 0.75f, 1.0f),
                TextColor       = NSColor.DisabledControlText,
                Bordered        = false,
                Editable        = false,
                Frame           = new RectangleF (
                    new PointF (85, ContentView.Frame.Height - 60),
                    new SizeF (320, 20)),
                StringValue     = SparkleShare.Controller.CurrentUser.Email,
            };

            this.balloon_text_field = new NSTextField () {
                Alignment       = NSTextAlignment.Left,
                BackgroundColor = NSColor.White,
                Bordered        = false,
                Editable        = true,
                Frame           = new RectangleF (
                    new PointF (30, ContentView.Frame.Height - 137),
                    new SizeF (418, 48))
            };

            (this.balloon_text_field.Cell as NSTextFieldCell).PlaceholderString  = "Anything to add?";
            (this.balloon_text_field.Cell as NSTextFieldCell).LineBreakMode      = NSLineBreakMode.ByWordWrapping;
            (this.balloon_text_field.Cell as NSTextFieldCell).UsesSingleLineMode = false;

            this.balloon_text_field.Cell.FocusRingType = NSFocusRingType.None;

            this.cancel_button = new NSButton () {
                Title = "Cancel",
                BezelStyle = NSBezelStyle.Rounded,
                Frame      = new RectangleF (Frame.Width - 15 - 105 * 2, 12, 105, 32),
            };

            this.sync_button = new NSButton () {
                Title = "Sync",
                BezelStyle = NSBezelStyle.Rounded,
                Frame      = new RectangleF (Frame.Width - 15 - 105, 12, 105, 32),
            };

            this.cancel_button.Activated += delegate { Controller.CancelClicked (); };
            this.sync_button.Activated += delegate { Controller.SyncClicked (this.balloon_text_field.StringValue); };

            DefaultButtonCell = this.sync_button.Cell;

            if (BackingScaleFactor >= 2)
                this.balloon_image = NSImage.ImageNamed ("text-balloon@2x");
            else
                this.balloon_image = NSImage.ImageNamed ("text-balloon");

            this.balloon_image.Size = new SizeF (438, 72);
            this.balloon_image_view = new NSImageView () {
                Image = this.balloon_image,
                Frame = new RectangleF (21, ContentView.Frame.Height - 145, 438, 72)
            };

            if (!string.IsNullOrEmpty (Controller.AvatarFilePath))
                this.user_image = new NSImage (Controller.AvatarFilePath);
            else
                this.user_image = NSImage.ImageNamed ("user-icon-default");

            this.user_image.Size = new SizeF (48, 48);
            this.user_image_view = new NSImageView () {
                Image = this.user_image,
                Frame = new RectangleF (21, ContentView.Frame.Height - 65, 48, 48)
            };

            this.user_image_view.WantsLayer          = true;
            this.user_image_view.Layer.CornerRadius  = 5.0f;
            this.user_image_view.Layer.MasksToBounds = true;

            ContentView.AddSubview (this.cover);
            ContentView.AddSubview (this.cancel_button);
            ContentView.AddSubview (this.sync_button);
            ContentView.AddSubview (this.user_name_text_field);
            ContentView.AddSubview (this.user_email_text_field);

            ContentView.AddSubview (this.user_image_view);
            ContentView.AddSubview (this.balloon_image_view);
            ContentView.AddSubview (this.balloon_text_field);

            MakeFirstResponder ((NSResponder) this.balloon_text_field);
        }
Exemplo n.º 19
0
 private NSView ViewToBeAdded()
 {
     NSBox box = new NSBox(NSRect.NSMakeRect(0.0f, 0.0f, BOXWIDTH, BOXHEIGHT));
     box.BoxType = NSBoxType.NSBoxCustom;
     box.BorderType = NSBorderType.NSLineBorder;
     box.TitlePosition = NSTitlePosition.NSNoTitle;
     box.FillColor = this.boxColorField.Color;
     box.Autorelease();
     return box;
 }
Exemplo n.º 20
0
 private void UpdateServerButtonColors(NSBox box)
 {
     box.FillColor   = Colors.HopBtnColor;
     box.BorderColor = Colors.HopBtnBorderColor;
 }
Exemplo n.º 21
0
        private void CreateAbout()
        {
            Box = new NSBox () {
                FillColor = NSColor.White,
                Frame = new RectangleF (-1, Frame.Height - 105, Frame.Width + 2, 105),
                BoxType = NSBoxType.NSBoxCustom
            };

            HeaderTextField = new NSTextField () {
                StringValue     = "SparkleShare",
                Frame           = new RectangleF (22, Frame.Height - 89, 318, 48),
                BackgroundColor = NSColor.White,
                Bordered        = false,
                Editable        = false,
                Font            = NSFontManager.SharedFontManager.FontWithFamily
                    ("Lucida Grande", NSFontTraitMask.Condensed, 0, 24)
            };

            VersionTextField = new NSTextField () {
                StringValue     = Defines.VERSION,
                Frame           = new RectangleF (22, Frame.Height - 94, 318, 22),
                BackgroundColor = NSColor.White,
                Bordered        = false,
                Editable        = false,
                Font            = NSFontManager.SharedFontManager.FontWithFamily
                    ("Lucida Grande", NSFontTraitMask.Unbold, 0, 11),
                TextColor       = NSColor.DisabledControlText
            };

            UpdatesTextField = new NSTextField () {
                StringValue     = "Checking for updates...",
                Frame           = new RectangleF (22, Frame.Height - 222, 318, 98),
                BackgroundColor = NSColor.WindowBackground,
                Bordered        = false,
                Editable        = false,
                Font            = NSFontManager.SharedFontManager.FontWithFamily
                    ("Lucida Grande", NSFontTraitMask.Unbold, 0, 11),
                TextColor       = NSColor.DisabledControlText
            };

            CreditsTextField = new NSTextField () {
                StringValue     = @"Copyright © 2010–" + DateTime.Now.Year + " Hylke Bons and others" +
                                   "\n" +
                                   "\n" +
                                   "SparkleShare is Free and Open Source Software. You are free to use, modify, and redistribute it " +
                                   "under the GNU General Public License version 3 or later.",
                Frame           = new RectangleF (22, Frame.Height - 250, 318, 98),
                BackgroundColor = NSColor.WindowBackground,
                Bordered        = false,
                Editable        = false,
                Font            = NSFontManager.SharedFontManager.FontWithFamily
                    ("Lucida Grande", NSFontTraitMask.Unbold, 0, 11),
            };

            WebsiteButton = new NSButton () {
                Frame = new RectangleF (12, 12, 120, 32),
                Title = "Visit Website",
                BezelStyle = NSBezelStyle.Rounded,
                Font = SparkleUI.Font
            };

            WebsiteButton.Activated += delegate {

                NSUrl url = new NSUrl ("http://www.sparkleshare.org/");
                NSWorkspace.SharedWorkspace.OpenUrl (url);

            };

            CreditsButton = new NSButton () {
                Frame = new RectangleF (Frame.Width - 12 - 120, 12, 120, 32),
                Title = "Show Credits",
                BezelStyle = NSBezelStyle.Rounded,
                Font = SparkleUI.Font
            };

            CreditsButton.Activated += delegate {

                NSUrl url = new NSUrl ("http://www.sparkleshare.org/credits/");
                NSWorkspace.SharedWorkspace.OpenUrl (url);

            };

            ContentView.AddSubview (Box);
            ContentView.AddSubview (HeaderTextField);
            ContentView.AddSubview (VersionTextField);
            ContentView.AddSubview (UpdatesTextField);
            ContentView.AddSubview (CreditsTextField);
            ContentView.AddSubview (CreditsButton);
            ContentView.AddSubview (WebsiteButton);
        }
Exemplo n.º 22
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();
                    }
                });
            };
        }
Exemplo n.º 23
0
        public override NSView GetView(NSOutlineView outlineView, NSTableColumn tableColumn, NSObject item)
        {

            NSClipView view = (NSClipView)outlineView.MakeView(CellIdentifier, this);
            NSTextField exprView = (NSTextField)(view == null ? null : view.Subviews[0]);
            NSTextField textView;
            NSTextField textView1 = (NSTextField)(view == null ? null : view.Subviews[3]);


            // Cast item
            var interval = item as Interval;

            if (view == null)
            {
                

                view = new NSClipView
                {
                    Identifier = CellIdentifier,
                    AutoresizesSubviews = true,
                    BackgroundColor = NSColor.Clear,
                    AutoresizingMask = NSViewResizingMask.WidthSizable,
                    WantsLayer = true
                };

                exprView = new NSTextField
                {
                    Alignment = NSTextAlignment.Center,
                    Selectable = false,
                    Editable = false,
                    DrawsBackground = false,
                    Bordered = false,
                    LineBreakMode = NSLineBreakMode.Clipping
                };

                exprView.RotateByAngle(-90);

                exprView.SetFrameOrigin(new CGPoint(0, 2));
                exprView.SetFrameSize(new CGSize(13, 28));

                NSBox line = new NSBox
                {
                    BoxType = NSBoxType.NSBoxSeparator
                };

                line.SetFrameSize(new CGSize(2, 23));
                line.SetFrameOrigin(new CGPoint(exprView.Frame.Width + 3, 5));

                textView = new NSTextField
                {
                    Selectable = false,
                    Editable = false,
                    DrawsBackground = false,
                    Bordered = false
                };
                textView.StringValue = "Время вып.\nКоэф.эффект.";
                textView.SetFrameSize(textView.FittingSize);
                textView.SetFrameOrigin(new CGPoint(line.Frame.Location.X + 10, 0));

                textView1 = new NSTextField
                {
                    Selectable = false,
                    Editable = false,
                    DrawsBackground = false,
                    Bordered = false
                };

                textView1.SetFrameOrigin(new CGPoint(textView.Frame.Location.X + textView.Frame.Width + 3, 0));

                view.AddSubview(exprView);
                view.AddSubview(line);
                view.AddSubview(textView);
                view.AddSubview(textView1);
            }

            CAGradientLayer gradientLayer = new CAGradientLayer();
            List<CGColor> colors = new List<CGColor>();
            colors.Add(OxyColors.Transparent.ToCGColor());
            if (interval.Info.times.comm >= 0.2 * viewController.plotStatMaxTime)
            {
                colors.Insert(0, OxyColors.Transparent.ToCGColor());
                colors.Add(OxyColors.GreenYellow.ToCGColor());
            }
            if (interval.Info.times.idle >= 0.2 * viewController.plotStatMaxTime)
            {
                colors.Insert(0, OxyColors.Transparent.ToCGColor());
                colors.Add(OxyColors.LightSkyBlue.ToCGColor());
            }
            if (interval.Info.times.insuf_user >= 0.2 * viewController.plotStatMaxTime)
            {
                colors.Insert(0, OxyColors.Transparent.ToCGColor());
                colors.Add(OxyColors.Orchid.ToCGColor());
            }
            if (interval.Info.times.insuf_sys >= 0.2 * viewController.plotStatMaxTime)
            {
                colors.Insert(0, OxyColors.Transparent.ToCGColor());
                colors.Add(OxyColors.Pink.ToCGColor());
            }
            if (colors.Count == 1)
                colors.Add(colors[0]);
            gradientLayer.Colors = colors.ToArray();
            gradientLayer.StartPoint = new CGPoint(.0, .0);
            gradientLayer.EndPoint = new CGPoint(1.0, .0);
            view.Layer = gradientLayer;

            // Setup view based on the column selected
            switch (interval.Info.id.t)
            {
                case (int)InterTypes.USER:
                    exprView.StringValue = interval.Info.id.expr.ToString();
                    break;
                case (int)InterTypes.SEQ:
                    exprView.StringValue = "Посл";
                    exprView.Font = NSFont.FromFontName("Helvetica Neue", 10);
                    break;
                case (int)InterTypes.PAR:
                    exprView.StringValue = "Пар";
                    exprView.Font = NSFont.FromFontName("Helvetica Neue", 10);
                    break;
            }

            textView1.StringValue = "➢   " + interval.Info.times.exec_time.ToString("F3") + "s\n"
                + "➢   " + interval.Info.times.efficiency.ToString("F3");
            textView1.SetFrameSize(textView1.FittingSize);

            return view;
        }
Exemplo n.º 24
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;
                    });
                }
            };
        }
        public override NSView GetView(NSOutlineView outlineView, NSTableColumn tableColumn, NSObject item)
        {
            // This pattern allows you reuse existing views when they are no-longer in use.
            // If the returned view is null, you instance up a new view
            // If a non-null view is returned, you modify it enough to reflect the new data

            NSClipView  view     = (NSClipView)outlineView.MakeView(CellIdentifier, this);
            NSTextField exprView = (NSTextField)(view == null ? null : view.Subviews[0]);
            NSBox       line     = (NSBox)(view == null ? null : view.Subviews[1]);

            // Cast item
            var interval  = item as Interval;
            var intervals = ViewController.CompareList.IntervalsList[interval.Row];

            if (view == null)
            {
                view = new NSClipView
                {
                    Identifier          = CellIdentifier,
                    AutoresizesSubviews = true,
                    DrawsBackground     = false,
                    WantsLayer          = true,
                    AutoresizingMask    = NSViewResizingMask.WidthSizable
                };

                exprView = new NSTextField
                {
                    Alignment       = NSTextAlignment.Center,
                    Selectable      = false,
                    Editable        = false,
                    DrawsBackground = false,
                    Bordered        = false,
                    LineBreakMode   = NSLineBreakMode.Clipping
                };

                exprView.RotateByAngle(-90);

                exprView.SetFrameOrigin(new CGPoint(0, 2));
                exprView.SetFrameSize(new CGSize(13, 28));

                line = new NSBox
                {
                    BoxType = NSBoxType.NSBoxSeparator
                };

                line.SetFrameSize(new CGSize(2, 23));
                line.SetFrameOrigin(new CGPoint(exprView.Frame.Width + 3, 5));

                view.AddSubview(exprView);
                view.AddSubview(line);
            }
            else
            {
                for (int i = view.Subviews.Length - 1; i > 1; --i)
                {
                    view.Subviews[i].RemoveFromSuperview();
                }
            }

            if (ViewController.CompareList.GetCount() <= 4)
            {
                view.Layer = null;

                //---  Создаем ячейки для интервалов  ---//
                nfloat offset = 0;
                for (var i = intervals.Count - 1; i >= 0; --i)
                {
                    var gradientLayer = MakeGradLayer(intervals[i]);

                    var interStack = new NSStackView
                    {
                        Orientation         = NSUserInterfaceLayoutOrientation.Vertical,
                        WantsLayer          = true,
                        AutoresizesSubviews = false
                    };

                    var val = new NSTextField
                    {
                        Alignment       = NSTextAlignment.Center,
                        Selectable      = false,
                        Editable        = false,
                        DrawsBackground = false,
                        Bordered        = false,
                        BackgroundColor = NSColor.Clear,
                        WantsLayer      = true
                    };

                    val.StringValue = intervals[i].times.exec_time.ToString("F1")
                                      + "\n" + intervals[i].times.efficiency.ToString("F1");
                    gradientLayer.Frame = new CGRect(new CGPoint(0, 0), val.FittingSize);
                    interStack.Layer.InsertSublayerBelow(gradientLayer, val.Layer);
                    interStack.Alignment = NSLayoutAttribute.CenterY;
                    interStack.SetFrameSize(val.FittingSize);
                    interStack.AddView(val, NSStackViewGravity.Top);

                    offset += val.FittingSize.Width;
                    interStack.AutoresizingMask = NSViewResizingMask.MinXMargin;
                    interStack.SetFrameOrigin(new CGPoint(view.Bounds.Width - offset, 0));
                    view.AddSubview(interStack);
                }
            }
            else
            {
                int maxNum, minNum, maxLostNum;
                (maxNum, minNum, maxLostNum) = GetMaxMinStats(intervals);

                NSTextField textView = new NSTextField
                {
                    Selectable      = false,
                    Editable        = false,
                    DrawsBackground = false,
                    Bordered        = false
                };
                textView.StringValue = "Max " + ViewController.CompareList
                                       .At(maxNum).Info.p_heading.Replace('*', 'x') + "\nMin "
                                       + ViewController.CompareList
                                       .At(minNum).Info.p_heading.Replace('*', 'x');
                textView.SetFrameSize(textView.FittingSize);
                textView.SetFrameOrigin(new CGPoint(line.Frame.Location.X + 10, 0));

                NSTextField textView1 = new NSTextField
                {
                    Selectable      = false,
                    Editable        = false,
                    DrawsBackground = false,
                    Bordered        = false
                };

                textView1.SetFrameOrigin(new CGPoint(textView.Frame.Location.X + textView.Frame.Width + 4, 0));

                textView1.StringValue = " ➢  " + intervals[maxNum].times.exec_time.ToString("F3") + "s\n"
                                        + " ➢  " + intervals[minNum].times.exec_time.ToString("F3") + "s";
                textView1.SetFrameSize(textView1.FittingSize);

                var gradientLayer = MakeGradLayer(intervals[maxLostNum], false);
                view.WantsLayer = true;
                view.Layer      = gradientLayer;
                view.AddSubview(textView);
                view.AddSubview(textView1);
            }

            //---  Устанавливаем значение Expr  ---//
            switch (interval.Info.id.t)
            {
            case (int)InterTypes.USER:
                exprView.StringValue = interval.Info.id.expr.ToString();
                break;

            case (int)InterTypes.SEQ:
                exprView.StringValue = "Посл";
                exprView.Font        = NSFont.FromFontName("Helvetica Neue", 10);
                break;

            case (int)InterTypes.PAR:
                exprView.StringValue = "Пар";
                exprView.Font        = NSFont.FromFontName("Helvetica Neue", 10);
                break;
            }

            return(view);
        }
Exemplo n.º 26
0
        public SparkleEventLog()
            : base()
        {
            using (var a = new NSAutoreleasePool ())
            {
                Title    = "Recent Changes";
                Delegate = new SparkleEventsDelegate ();
                // TODO: Window needs to be made resizable

                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.web_view = new WebView (new RectangleF (0, 0, 480, 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.background);
                ContentView.AddSubview (this.separator);
                ContentView.AddSubview (this.progress_indicator);
                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 ();

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

            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;
                    });
                }
            };
        }
Exemplo n.º 27
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;
        }
Exemplo n.º 28
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;
                    });
                }
            };
        }
Exemplo n.º 29
0
        protected override IView OnConvertToView(FigmaNode currentNode, ViewNode parentNode, ViewRenderService rendererService)
        {
            var frame = (FigmaFrame)currentNode;
            var box   = new NSBox();

            currentNode.TryGetNativeControlType(out FigmaControlType controlType);

            if (controlType == FigmaControlType.Separator)
            {
                box.BoxType = NSBoxType.NSBoxSeparator;
            }

            if (controlType == FigmaControlType.BoxCustom)
            {
                box.BoxType     = NSBoxType.NSBoxCustom;
                box.BorderWidth = 0;

                RectangleVector rectangle = frame.children
                                            .OfType <RectangleVector>()
                                            .FirstOrDefault();

                if (rectangle != null)
                {
                    if (rectangle.styles != null)
                    {
                        foreach (var styleMap in rectangle.styles)
                        {
                            if (rendererService.NodeProvider.TryGetStyle(styleMap.Value, out FigmaStyle style))
                            {
                                if (styleMap.Key == "fill")
                                {
                                    box.FillColor = ColorService.GetNSColor(style.name);
                                }

                                if (styleMap.Key == "stroke")
                                {
                                    box.BorderColor = ColorService.GetNSColor(style.name);
                                    box.BorderWidth = rectangle.strokeWeight;
                                }
                            }
                        }
                    }

                    box.CornerRadius = rectangle.cornerRadius;
                }
            }

            if (controlType == FigmaControlType.Box)
            {
                FigmaText text = frame.children
                                 .OfType <FigmaText>()
                                 .FirstOrDefault(s => (s.name == ComponentString.TITLE && s.visible));

                if (text != null)
                {
                    box.Title = rendererService.GetTranslatedText(text);
                }
                else
                {
                    box.Title = string.Empty;
                }
            }

            return(new View(box));
        }
Exemplo n.º 30
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;
                    });
                }
            };
        }
Exemplo n.º 31
0
        public SparkleLog(string path)
            : base()
        {
            LocalPath = path;

            Delegate = new SparkleLogDelegate ();

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

            // Open slightly off center for each consecutive window
            if (SparkleUI.OpenLogs.Count > 0) {

                RectangleF offset = new RectangleF (Frame.X + (SparkleUI.OpenLogs.Count * 20),
                    Frame.Y - (SparkleUI.OpenLogs.Count * 20), Frame.Width, Frame.Height);

                SetFrame (offset, true);

            }

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

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

            CreateEventLog ();
            UpdateEventLog ();

            ContentView.AddSubview (WebView);

            OpenFolderButton = new NSButton (new RectangleF (16, 12, 120, 32)) {
                Title = "Open Folder",
                BezelStyle = NSBezelStyle.Rounded	,
                Font = SparkleUI.Font
            };

                OpenFolderButton.Activated += delegate {
                    SparkleShare.Controller.OpenSparkleShareFolder (LocalPath);
                };

            ContentView.AddSubview (OpenFolderButton);

            CloseButton = new NSButton (new RectangleF (480 - 120 - 16, 12, 120, 32)) {
                Title = "Close",
                BezelStyle = NSBezelStyle.Rounded,
                Font = SparkleUI.Font
            };

                CloseButton.Activated += delegate {
                    InvokeOnMainThread (delegate {
                        PerformClose (this);
                    });
                };

            ContentView.AddSubview (CloseButton);

            string name = Path.GetFileName (LocalPath);
            Title = String.Format ("Events in ‘{0}’", name);

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

            ContentView.AddSubview (Separator);

            OrderFrontRegardless ();
        }