public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            var stackView = new NSStackView
            {
                Orientation = NSUserInterfaceLayoutOrientation.Vertical,
                Frame       = View.Frame,
            };

            var editBenchCount = AddArrangedLabelAndField(stackView, "Benchmark count:", "5");
            var editStrings    = AddArrangedLabelAndField(stackView, "NSString allocations:", "10000");
            var editViews      = AddArrangedLabelAndField(stackView, "NSView allocations", "0");

            stackView.AddArrangedSubview(NSButton.CreateButton("Test", () =>
            {
                int benchCount    = int.Parse(editBenchCount.StringValue);
                int nsstringCount = int.Parse(editStrings.StringValue);
                int nsviewCount   = int.Parse(editViews.StringValue);

                var bench = new AllocatorBenchmark(benchCount, nsstringCount, nsviewCount);
                bench.Run();
            }));

            View.AddSubview(stackView);

            // Do any additional setup after loading the view.
        }
Пример #2
0
        public void NSStackViewShouldCreateWithViews()
        {
            view = NSStackView.FromViews(new [] { first, second });

            Assert.IsNotNull(view, "NSStackViewCreateWithViews - Failed to create view");
            Assert.IsTrue(view.Views.Length == 2, "NSStackViewShouldCreateWithViews - StackView does not have 2 views");
        }
Пример #3
0
        NSView CreateRow(string label, string [] items, int selectedItem, Action <int> handler)
        {
            var stackView = new NSStackView {
                Orientation  = NSUserInterfaceLayoutOrientation.Horizontal,
                Distribution = NSStackViewDistribution.Fill,
                Spacing      = 8
            };

            var labelView = new Views.XILabel {
                StringValue = label
            };

            labelView.SizeToFit();
            stackView.AddView(labelView, NSStackViewGravity.Leading);

            var menuView = new NSPopUpButton();

            menuView.AddItems(items);
            menuView.SelectItem(selectedItem);
            stackView.AddView(menuView, NSStackViewGravity.Trailing);

            menuView.Activated += (sender, e) => handler((int)menuView.IndexOfSelectedItem);

            return(stackView);
        }
Пример #4
0
        public override IDisposable Login(LoginConfig config) => this.Present(() =>
        {
            var alert = new NSAlert
            {
                AlertStyle      = NSAlertStyle.Informational,
                MessageText     = config.Title ?? string.Empty,
                InformativeText = config.Message ?? string.Empty
            };
            alert.AddButton(config.OkText);
            alert.AddButton(config.CancelText);

            var inputView = new NSStackView(new CGRect(0, 2, 200, 58));
            var txtUser   = new NSTextField(new CGRect(0, 28, 200, 24))
            {
                PlaceholderString = config.LoginPlaceholder,
                StringValue       = config.LoginValue ?? string.Empty
            };
            var txtPassword = new NSSecureTextField(new CGRect(0, 2, 200, 24))
            {
                PlaceholderString = config.PasswordPlaceholder
            };

            inputView.AddSubview(txtUser);
            inputView.AddSubview(txtPassword);

            alert.AccessoryView = inputView;
            alert.Layout();

            alert.BeginSheetForResponse(this.windowFunc(), result => config.OnAction?.Invoke(new LoginResult(result == 1000, txtUser.StringValue, txtPassword.StringValue)));
            return(alert);
        });
Пример #5
0
        public PlaylistDetailView()
        {
            TitleLabel            = NSLabel.CreateWithFont(TitleFontName, TitleFontSize);
            TitleLabel.Identifier = "TitleLabel";
            TitleLabel.TextColor  = NSColor.FromRgb(51, 51, 51);

            DescriptionLabel            = NSLabel.CreateWithFont(DescriptionFontName, DescriptionFontSize);
            DescriptionLabel.Identifier = "DescriptionLabel";
            DescriptionLabel.TextColor  = NSColor.FromRgb(142, 142, 142);

            SongsTable = new SongsListView();

            outerStack = new NSStackView();
            outerStack.TranslatesAutoresizingMaskIntoConstraints = false;
            outerStack.Orientation  = NSUserInterfaceLayoutOrientation.Vertical;
            outerStack.Distribution = NSStackViewDistribution.Fill;
            outerStack.Spacing      = 10;
            outerStack.EdgeInsets   = new NSEdgeInsets(20, 0, 0, 0);

            outerStack.AddArrangedSubview(TitleLabel);
            outerStack.AddArrangedSubview(DescriptionLabel);
            outerStack.AddArrangedSubview(SongsTable);

            AddSubview(outerStack);

            AddConstraint(MinimumHeight(SongsTable, 100));
            AddConstraints(FillHorizontal(true, TitleLabel, DescriptionLabel));
            AddConstraints(FillHorizontal(outerStack, false));
            AddConstraints(FillVertical(outerStack, false));
        }
Пример #6
0
        public void NSStackViewShouldRemoveView()
        {
            view = NSStackView.FromViews(new [] { first, second });

            view.RemoveView(second);

            Assert.IsTrue(view.Views.Length == 1, "NSStackViewShouldRemoveView - Failed to remove view");
        }
Пример #7
0
 public Horizontal()
 {
     stackView = new NSStackView
     {
         Orientation = NSUserInterfaceLayoutOrientation.Horizontal,
         Alignment   = NSLayoutAttribute.NoAttribute
     };
 }
Пример #8
0
        public static void AddArrangedSubview(this NSStackView stackView, NSView view, bool expandHorizontally, bool expandVertically)
        {
            stackView.AddArrangedSubview(view);

            view.SetContentHuggingPriorityForOrientation(expandHorizontally ? RenderingPriority : LowPriority, NSLayoutConstraintOrientation.Horizontal);
            view.SetContentHuggingPriorityForOrientation(expandVertically ? LowPriority : RenderingPriority, NSLayoutConstraintOrientation.Vertical);
            view.SetContentCompressionResistancePriority(expandHorizontally ? RenderingPriority : LowPriority, NSLayoutConstraintOrientation.Horizontal);
            view.SetContentCompressionResistancePriority(expandVertically ? LowPriority : RenderingPriority, NSLayoutConstraintOrientation.Vertical);
        }
Пример #9
0
        static void Main(string[] args)
        {
            NSApplication.Init();
            NSApplication.SharedApplication.ActivationPolicy = NSApplicationActivationPolicy.Regular;

            var xPos = NSScreen.MainScreen.Frame.Width / 2;
            var yPos = NSScreen.MainScreen.Frame.Height / 2;

            var mainWindow = new MacAccInspectorWindow(new CGRect(xPos, yPos, 300, 368), NSWindowStyle.Titled | NSWindowStyle.Resizable | NSWindowStyle.Closable, NSBackingStore.Buffered, false);
            var token      = Environment.GetEnvironmentVariable("TOKEN");

            FigmaEnvirontment.SetAccessToken(token);

            var stackView = new NSStackView()
            {
                Orientation = NSUserInterfaceLayoutOrientation.Vertical
            };
            var button = new NSButton()
            {
                Title = "Refresh"
            };

            stackView.AddArrangedSubview(button);

            scrollView = new NSScrollView()
            {
                HasVerticalScroller               = true,
                HasHorizontalScroller             = true,
                AutomaticallyAdjustsContentInsets = false
            };
            stackView.AddArrangedSubview(scrollView);

            scrollView.AutohidesScrollers = false;
            scrollView.BackgroundColor    = NSColor.Orange;
            scrollView.ScrollerStyle      = NSScrollerStyle.Legacy;
            mainWindow.ContentView        = stackView;

            var contentView = new NSView {
                Frame = new CGRect(CGPoint.Empty, mainWindow.Frame.Size)
            };

            contentView.AutoresizingMask = NSViewResizingMask.WidthSizable | NSViewResizingMask.HeightSizable;

            scrollView.DocumentView = contentView;

            Refresh(contentView);

            button.Activated += (sender, e) =>
            {
                //Refresh (contentView);
            };

            mainWindow.MakeKeyAndOrderFront(null);
            NSApplication.SharedApplication.ActivateIgnoringOtherApps(true);
            NSApplication.SharedApplication.Run();
        }
Пример #10
0
        public void SetUp()
        {
            Asserts.EnsureMavericks();

            view = new NSStackView();

            first  = new NSView();
            second = new NSView();
            third  = new NSView();
        }
Пример #11
0
        static void Main(string[] args)
        {
            NSApplication.Init();
            NSApplication.SharedApplication.ActivationPolicy = NSApplicationActivationPolicy.Regular;

            AgentEnvirontment.Current.Initialize(new AgentDelegate(), new SoundPlayer());

            var xPos = NSScreen.MainScreen.Frame.Width / 2;
            var yPos = NSScreen.MainScreen.Frame.Height / 2;

            var mainWindow = new NSWindow(new CGRect(xPos, yPos, 200, 150), NSWindowStyle.Borderless, NSBackingStore.Buffered, false)
            {
                Title = "ClippySharp",

                IsOpaque        = false,
                BackgroundColor = NSColor.FromRgba(red: 1, green: 1, blue: 1f, alpha: 0.5f)
            };

            mainWindow.MovableByWindowBackground = true;

            var stackView = new NSStackView()
            {
                Orientation  = NSUserInterfaceLayoutOrientation.Vertical,
                Distribution = NSStackViewDistribution.Fill
            };

            mainWindow.ContentView = stackView;

            agentPopupButton = new NSPopUpButton();
            stackView.AddArrangedSubview(agentPopupButton);

            foreach (var item in AgentEnvirontment.Current.GetAgents())
            {
                agentPopupButton.AddItem(item);
            }

            animationPopupButton = new NSPopUpButton();
            stackView.AddArrangedSubview(animationPopupButton);

            agentView = new AgentView();
            stackView.AddArrangedSubview(agentView);

            agentPopupButton.Activated += AgentPopupButton_Activated;

            animationPopupButton.Activated += AnimationPopupButton_Activated;

            AgentPopupButton_Activated(null, null);

            mainWindow.MakeKeyAndOrderFront(null);
            NSApplication.SharedApplication.ActivateIgnoringOtherApps(true);
            NSApplication.SharedApplication.Run();
        }
Пример #12
0
        public BreadcrumbView()
        {
            TranslatesAutoresizingMaskIntoConstraints = false;
            WantsLayer = true;
            items      = new List <BreadcrumbViewItem> ();

            stack             = new NSStackView();
            stack.Orientation = NSUserInterfaceLayoutOrientation.Horizontal;
            stack.TranslatesAutoresizingMaskIntoConstraints = false;

            AddSubview(stack);
            BuildConstraints();
        }
Пример #13
0
        //public override bool IsOpaque => true;

        void Initialize()
        {
            //WantsLayer = true;
            TranslatesAutoresizingMaskIntoConstraints = false;

            tabsStack = new NSStackView();
            tabsStack.TranslatesAutoresizingMaskIntoConstraints = false;
            tabsStack.Orientation = NSUserInterfaceLayoutOrientation.Horizontal;
            tabsStack.Spacing     = 0;

            AddSubview(tabsStack);

            AddConstraints(FillHorizontal(false, tabsStack));
            AddConstraints(FillVertical(false, tabsStack));

            tabViews = new Dictionary <string, SearchResultsTabView> ();
        }
        NSTextField AddArrangedLabelAndField(NSStackView toView, string label, string fieldValue)
        {
            var editField = new NSTextField {
                StringValue = fieldValue,
            };

            toView.AddArrangedSubview(NSStackView.FromViews(new NSView[] {
                new NSTextField()
                {
                    StringValue = label,
                    Editable    = false,
                },
                editField
            }));

            return(editField);
        }
Пример #15
0
        public override NSView GetViewForItem(NSTableView tableView, NSTableColumn tableColumn, nint row)
        {
            var result = new NSStackView()
            {
                Orientation  = NSUserInterfaceLayoutOrientation.Horizontal,
                Alignment    = NSLayoutAttribute.CenterY,
                Spacing      = 10,
                Distribution = NSStackViewDistribution.Fill,
                TranslatesAutoresizingMaskIntoConstraints = false
            };

            var item = data[(int)row];

            result.AddArrangedSubview(NativeViewHelper.CreateLabel(item.Name));
            result.AddArrangedSubview(new NSView()
            {
                TranslatesAutoresizingMaskIntoConstraints = false
            });
            return(result);
        }
Пример #16
0
        public FigmaViewContent(FilePath fileName)
        {
            FigmaEnvirontment.SetAccessToken(FigmaRuntime.Token);

            this.fileName = fileName;
            ContentName   = fileName;

            container                       = new NSStackView();
            container.Spacing               = 10;
            container.WantsLayer            = true;
            container.Layer.BackgroundColor = NSColor.DarkGray.CGColor;

            container.Distribution = NSStackViewDistribution.Fill;
            container.Orientation  = NSUserInterfaceLayoutOrientation.Vertical;

            _content           = GtkMacInterop.NSViewToGtkWidget(container);
            _content.CanFocus  = true;
            _content.Sensitive = true;

            var scrollView = new NSScrollView()
            {
                HasVerticalScroller   = true,
                HasHorizontalScroller = true,
            };

            scrollView.AutohidesScrollers = false;
            scrollView.BackgroundColor    = NSColor.DarkGray;
            scrollView.ScrollerStyle      = NSScrollerStyle.Legacy;

            renderer = new NSView();
            scrollView.DocumentView   = renderer;
            renderer.AutoresizingMask = NSViewResizingMask.WidthSizable | NSViewResizingMask.HeightSizable;

            container.AddArrangedSubview(scrollView);



            //IdeApp.Workbench.ActiveDocument.Editor.TextChanged += Editor_TextChanged;

            _content.ShowAll();
        }
Пример #17
0
        public FigmaFileDocumentController()
        {
            container = new NSStackView();

            container.Spacing               = 10;
            container.WantsLayer            = true;
            container.Layer.BackgroundColor = NSColor.DarkGray.CGColor;

            container.Distribution = NSStackViewDistribution.Fill;
            container.Orientation  = NSUserInterfaceLayoutOrientation.Vertical;

            _content           = GtkMacInterop.NSViewToGtkWidget(container);
            _content.CanFocus  = true;
            _content.Sensitive = true;

            var scrollView = new FNSScrollview()
            {
                HasVerticalScroller   = true,
                HasHorizontalScroller = true,
            };

            scrollView.AutohidesScrollers = false;
            scrollView.BackgroundColor    = NSColor.DarkGray;
            scrollView.ScrollerStyle      = NSScrollerStyle.Legacy;

            scrollViewWrapper = new ScrollView(scrollView);

            var contentView = new NSView();

            contentView.AutoresizingMask = NSViewResizingMask.WidthSizable | NSViewResizingMask.HeightSizable;
            scrollView.DocumentView      = contentView;

            container.AddArrangedSubview(scrollView);

            _content.ShowAll();

            grid          = PropertyPad.Instance.Control;
            grid.Changed += PropertyPad_Changed;
        }
        public override void LoadView()
        {
            var stack = new NSStackView()
            {
                Orientation = NSUserInterfaceLayoutOrientation.Vertical
            };

            this.materialEditor = new MaterialView {
                ViewModel = ViewModel?.MaterialDesign
            };

            this.alphaChannelEditor = new AlphaChannelEditor();
            this.alphaSpinEditor    = new ComponentSpinEditor(this.hostResources, this.alphaChannelEditor)
            {
                BackgroundColor = NSColor.Clear
            };
            this.alphaSpinEditor.ValueChanged += UpdateComponent;

            var alphaStack = new NSStackView()
            {
                Orientation = NSUserInterfaceLayoutOrientation.Horizontal
            };

            var alphaLabel = new UnfocusableTextField {
                StringValue = $"{Properties.Resources.Alpha}:",
                Alignment   = NSTextAlignment.Left,
            };

            alphaLabel.Cell.LineBreakMode = NSLineBreakMode.Clipping;

            alphaStack.AddView(alphaLabel, NSStackViewGravity.Trailing);
            alphaStack.AddView(this.alphaSpinEditor, NSStackViewGravity.Trailing);

            stack.AddView(this.materialEditor, NSStackViewGravity.Leading);
            stack.AddView(alphaStack, NSStackViewGravity.Trailing);

            View = stack;
        }
Пример #19
0
        public StatusWindow(CGRect frame) : base(frame, NSWindowStyle.Titled, NSBackingStore.Buffered, false)
        {
            IsOpaque           = false;
            ShowsToolbarButton = false;
            IgnoresMouseEvents = true;
            this.Title         = "KeyViewLoop Debug Window";
            var containerView = new NSView {
                TranslatesAutoresizingMaskIntoConstraints = false
            };

            ContentView = containerView;

            stackContainer = new NSStackView {
                Orientation = NSUserInterfaceLayoutOrientation.Vertical,
                Alignment   = NSLayoutAttribute.Leading,
                TranslatesAutoresizingMaskIntoConstraints = false
            };
            containerView.AddSubview(stackContainer);

            NSLayoutConstraint.Create(stackContainer, NSLayoutAttribute.Left, NSLayoutRelation.Equal, containerView, NSLayoutAttribute.Left, 1, 10);
            NSLayoutConstraint.Create(stackContainer, NSLayoutAttribute.Right, NSLayoutRelation.Equal, containerView, NSLayoutAttribute.Right, 1, 10);
            NSLayoutConstraint.Create(stackContainer, NSLayoutAttribute.Top, NSLayoutRelation.Equal, containerView, NSLayoutAttribute.Top, 1, 10);
            NSLayoutConstraint.Create(stackContainer, NSLayoutAttribute.Bottom, NSLayoutRelation.Equal, containerView, NSLayoutAttribute.Bottom, 1, 10);
        }
Пример #20
0
        protected virtual NSAlert CreateNativeActionSheet(ActionSheetConfig config)
        {
            var alert = new NSAlert
            {
                AlertStyle      = NSAlertStyle.Informational,
                MessageText     = config.Title ?? string.Empty,
                InformativeText = config.Message ?? string.Empty
            };

            if (config.Cancel != null)
            {
                alert.AddButton(config.Cancel.Text);
            }

            var extraSpace = config.Destructive == null ? 30 : 60;
            var inputView  = new NSStackView(new CGRect(0, 0, 200, (config.Options.Count * 30) + extraSpace));

            var yPos = config.Options.Count * 30 + (config.Destructive == null ? 0 : 1) * 30;

            foreach (var item in config.Options)
            {
                this.AddActionSheetOption(item, alert.Window, inputView, yPos);
                yPos -= 30;
            }

            if (config.Destructive != null)
            {
                this.AddActionSheetOption(config.Destructive, alert.Window, inputView, yPos, true);
            }

            alert.AccessoryView = inputView;
            alert.Layout();

            alert.BeginSheetForResponse(this.windowFunc(), _ => { });
            return(alert);
        }
Пример #21
0
        static NSStackView ArrangeAccessoryViews(NSView[] views, int viewWidth = 450, int spacing = 5)
        {
            if (views == null || views.Length == 0)
            {
                return(null);
            }

            var stackView = NSStackView.FromViews(views);

            stackView.Orientation  = NSUserInterfaceLayoutOrientation.Vertical;
            stackView.Distribution = NSStackViewDistribution.Fill;
            stackView.Alignment    = NSLayoutAttribute.Left;
            stackView.Spacing      = spacing;

            nfloat stackViewHeight = 0;

            foreach (var v in stackView.ArrangedSubviews)
            {
                stackViewHeight += v.Frame.Height;
            }

            stackView.Frame = new CGRect(0, 0, viewWidth, stackViewHeight);
            return(stackView);
        }
Пример #22
0
        public MacToolbox(ToolboxService toolboxService, IPadWindow container)
        {
            WantsLayer = true;

            keyViewLoopDelegate = new KeyViewLoopDelegate();

            verticalStackView = new UnfocusableStackView()
            {
                Orientation          = NSUserInterfaceLayoutOrientation.Vertical,
                Alignment            = NSLayoutAttribute.Leading,
                Spacing              = 0,
                Distribution         = NSStackViewDistribution.Fill,
                AccessibilityElement = false,
                WantsLayer           = true
            };
            AddSubview(verticalStackView);

            this.toolboxService = toolboxService;
            this.container      = container;

            #region Toolbar

            groupByCategoryImage = ImageService.GetIcon(Stock.GroupByCategory, Gtk.IconSize.Menu);
            var compactImage = ImageService.GetIcon(Stock.CompactDisplay, Gtk.IconSize.Menu);
            var addImage     = ImageService.GetIcon(Stock.Add, Gtk.IconSize.Menu);

            horizontalStackView = NativeViewHelper.CreateHorizontalStackView(IconsSpacing);
            verticalStackView.AddArrangedSubview(horizontalStackView);

            horizontalStackView.LeftAnchor.ConstraintEqualToAnchor(verticalStackView.LeftAnchor, 0).Active   = true;
            horizontalStackView.RightAnchor.ConstraintEqualToAnchor(verticalStackView.RightAnchor, 0).Active = true;

            horizontalStackView.EdgeInsets = new NSEdgeInsets(7, 7, 7, 7);

            //Horizontal container
            filterEntry = new NativeViews.SearchTextField();
            filterEntry.AccessibilityTitle = GettextCatalog.GetString("Search Toolbox");
            filterEntry.AccessibilityHelp  = GettextCatalog.GetString("Enter a term to search for it in the toolbox");
            filterEntry.Activated         += FilterTextChanged;

            horizontalStackView.AddArrangedSubview(filterEntry);

            filterEntry.SetContentCompressionResistancePriority((int)NSLayoutPriority.DefaultLow, NSLayoutConstraintOrientation.Horizontal);
            filterEntry.SetContentHuggingPriorityForOrientation((int)NSLayoutPriority.DefaultLow, NSLayoutConstraintOrientation.Horizontal);

            catToggleButton       = new NativeViews.ToggleButton();
            catToggleButton.Image = groupByCategoryImage.ToNSImage();
            catToggleButton.AccessibilityTitle = GettextCatalog.GetString("Show categories");
            catToggleButton.ToolTip            = GettextCatalog.GetString("Show categories");
            catToggleButton.AccessibilityHelp  = GettextCatalog.GetString("Toggle to show categories");
            catToggleButton.Activated         += ToggleCategorisation;

            horizontalStackView.AddArrangedSubview(catToggleButton);

            catToggleButton.SetContentCompressionResistancePriority((int)NSLayoutPriority.DefaultHigh, NSLayoutConstraintOrientation.Horizontal);
            catToggleButton.SetContentHuggingPriorityForOrientation((int)NSLayoutPriority.DefaultHigh, NSLayoutConstraintOrientation.Horizontal);

            compactModeToggleButton                    = new NativeViews.ToggleButton();
            compactModeToggleButton.Image              = compactImage.ToNSImage();
            compactModeToggleButton.ToolTip            = GettextCatalog.GetString("Use compact display");
            compactModeToggleButton.AccessibilityTitle = GettextCatalog.GetString("Compact Layout");
            compactModeToggleButton.AccessibilityHelp  = GettextCatalog.GetString("Toggle for toolbox to use compact layout");
            compactModeToggleButton.Activated         += ToggleCompactMode;

            horizontalStackView.AddArrangedSubview(compactModeToggleButton);

            compactModeToggleButton.SetContentCompressionResistancePriority((int)NSLayoutPriority.DefaultHigh, NSLayoutConstraintOrientation.Horizontal);
            compactModeToggleButton.SetContentHuggingPriorityForOrientation((int)NSLayoutPriority.DefaultHigh, NSLayoutConstraintOrientation.Horizontal);

            toolboxAddButton       = new NativeViews.ClickedButton();
            toolboxAddButton.Image = addImage.ToNSImage();
            toolboxAddButton.AccessibilityTitle = GettextCatalog.GetString("Add toolbox items");
            toolboxAddButton.AccessibilityHelp  = GettextCatalog.GetString("Add toolbox items");
            toolboxAddButton.ToolTip            = GettextCatalog.GetString("Add toolbox items");
            toolboxAddButton.Activated         += ToolboxAddButton_Clicked;

            horizontalStackView.AddArrangedSubview(toolboxAddButton);

            toolboxAddButton.SetContentCompressionResistancePriority((int)NSLayoutPriority.DefaultHigh, NSLayoutConstraintOrientation.Horizontal);
            toolboxAddButton.SetContentHuggingPriorityForOrientation((int)NSLayoutPriority.DefaultHigh, NSLayoutConstraintOrientation.Horizontal);

            #endregion

            toolboxWidget = new MacToolboxWidget()
            {
                AccessibilityTitle = GettextCatalog.GetString("Toolbox Toolbar"),
            };

            var scrollView = new UnfocusableScrollview()
            {
                HasVerticalScroller   = true,
                HasHorizontalScroller = false,
                DocumentView          = toolboxWidget
            };
            verticalStackView.AddArrangedSubview(scrollView);

            //update view when toolbox service updated
            toolboxService.ToolboxContentsChanged += ToolboxService_ToolboxContentsChanged;
            toolboxService.ToolboxConsumerChanged += ToolboxService_ToolboxConsumerChanged;

            toolboxWidget.DragBegin            += ToolboxWidget_DragBegin;
            toolboxWidget.ActivateSelectedItem += ToolboxWidget_ActivateSelectedItem;
            toolboxWidget.MenuOpened           += ToolboxWidget_MenuOpened;
            toolboxWidget.RegionCollapsed      += FilterTextChanged;

            toolboxWidget.KeyDownPressed += ToolboxWidget_KeyDownPressed;

            //set initial state
            toolboxWidget.ShowCategories   = catToggleButton.Active = true;
            compactModeToggleButton.Active = MonoDevelop.Core.PropertyService.Get("ToolboxIsInCompactMode", false);
            toolboxWidget.IsListMode       = !compactModeToggleButton.Active;

            //custom message
            var cell = new VerticalAlignmentTextCell(NSTextBlockVerticalAlignment.Middle)
            {
                Font            = NativeViewHelper.GetSystemFont(false, (int)NSFont.SmallSystemFontSize),
                LineBreakMode   = NSLineBreakMode.ByWordWrapping,
                Alignment       = NSTextAlignment.Center,
                Editable        = false,
                Bordered        = false,
                Bezeled         = false,
                DrawsBackground = false,
                Selectable      = false
            };

            messageTextField = new NSTextField {
                Cell       = cell,
                WantsLayer = true,
                Hidden     = true
            };
            AddSubview(messageTextField);

            keyViewLoopDelegate.AddViews(filterEntry, catToggleButton, compactModeToggleButton, toolboxAddButton, toolboxWidget);
            keyViewLoopDelegate.RecalculeNextResponderChain();
        }
Пример #23
0
        protected virtual void AddActionSheetOption(ActionSheetOption opt, NSWindow alertWindow, NSStackView containerView, int yPos, bool isDestructive = false)
        {
            var btn = new NSButton(new CGRect(0, yPos, 200, 28))
            {
                Title = opt.Text ?? string.Empty
            };

            if (isDestructive)
            {
                var colorTitle = new NSMutableAttributedString(btn.AttributedTitle);
                colorTitle.AddAttribute(NSStringAttributeKey.ForegroundColor, NSColor.Red, new NSRange(0, opt.Text.Length));
                btn.AttributedTitle = colorTitle;
            }

            if (opt.ItemIcon != null)
            {
                btn.Image = NSImage.ImageNamed(opt.ItemIcon);
            }

            btn.Activated += (sender, e) =>
            {
                this.windowFunc().EndSheet(alertWindow);
                opt.Action?.Invoke();
            };

            containerView.AddSubview(btn);
        }
Пример #24
0
        public static void NewPassword(SqliteConnection connection, SqliteConnection _conn)
        {
            var newPasswordInput = new NSStackView(new CGRect(0, 0, 300, 50));

            var originalPassword = new NSSecureTextField(new CGRect(0, 25, 300, 20));

            originalPassword.PlaceholderAttributedString = new Foundation.NSAttributedString("Type new password...");
            var confirmedPassword = new NSSecureTextField(new CGRect(0, 0, 300, 20));

            confirmedPassword.PlaceholderAttributedString = new Foundation.NSAttributedString("Confirm password...");

            newPasswordInput.AddSubview(originalPassword);
            newPasswordInput.AddSubview(confirmedPassword);

            var newPasswordAlert = new NSAlert()
            {
                AlertStyle      = NSAlertStyle.Informational,
                InformativeText = "Enter new password to secure SittingDucks",
                MessageText     = "Adding New Password",
            };
            var enterButton = newPasswordAlert.AddButton("Enter");

            originalPassword.NextKeyView  = confirmedPassword;
            confirmedPassword.NextKeyView = enterButton;

            newPasswordAlert.AccessoryView = newPasswordInput;
            newPasswordAlert.Layout();
            var result = newPasswordAlert.RunModal();

            if (result == 1000 && originalPassword.StringValue == confirmedPassword.StringValue)
            {
                bool shouldClose;
                var  encryptedPassword = EncryptionTool.Encrypt(originalPassword.StringValue);

                (_conn, shouldClose) = SqliteManager.OpenConnection(connection);

                // Execute query
                using (var command = connection.CreateCommand())
                {
                    // Create new command
                    command.CommandText = "UPDATE [System] SET ID = @COL1, Password = @COL2, INIT = @COL3";

                    // Populate with data from the record
                    command.Parameters.AddWithValue("@COL1", new Guid());
                    command.Parameters.AddWithValue("@COL2", encryptedPassword);
                    command.Parameters.AddWithValue("@COL3", true);

                    // Write to database
                    command.ExecuteNonQuery();
                }

                _conn = SqliteManager.CloseConnection(shouldClose, connection);

                newPasswordAlert.Dispose();

                var confirmPasswordAlert = new NSAlert()
                {
                    AlertStyle      = NSAlertStyle.Informational,
                    InformativeText = "Remember this password, store it somewhere safe! You will not be able to recover it if lost.",
                    MessageText     = "Password sucessfully saved",
                };
                confirmPasswordAlert.AddButton("OK");
                var confirmResult = confirmPasswordAlert.RunModal();

                if (confirmResult == 1000)
                {
                    confirmPasswordAlert.Dispose();
                }
            }
            else if (result == 1000 && originalPassword.StringValue != confirmedPassword.StringValue)
            {
                newPasswordAlert.AlertStyle      = NSAlertStyle.Warning;
                newPasswordAlert.InformativeText = "Passwords do not match";
            }
        }
Пример #25
0
        public MacToolbox(ToolboxService toolboxService, IPadWindow container)
        {
            Orientation          = NSUserInterfaceLayoutOrientation.Vertical;
            Alignment            = NSLayoutAttribute.Leading;
            Spacing              = 0;
            Distribution         = NSStackViewDistribution.Fill;
            AccessibilityElement = false;
            this.toolboxService  = toolboxService;
            this.container       = container;

            #region Toolbar

            groupByCategoryImage = ImageService.GetIcon(Stock.GroupByCategory, Gtk.IconSize.Menu);
            var compactImage = ImageService.GetIcon(Stock.CompactDisplay, Gtk.IconSize.Menu);
            var addImage     = ImageService.GetIcon(Stock.Add, Gtk.IconSize.Menu);

            horizontalStackView = NativeViewHelper.CreateHorizontalStackView(IconsSpacing);
            AddArrangedSubview(horizontalStackView);

            horizontalStackView.LeftAnchor.ConstraintEqualToAnchor(LeftAnchor, 0).Active   = true;
            horizontalStackView.RightAnchor.ConstraintEqualToAnchor(RightAnchor, 0).Active = true;

            horizontalStackView.EdgeInsets = new NSEdgeInsets(7, 7, 7, 7);

            //Horizontal container
            filterEntry = new NativeViews.SearchTextField();
            filterEntry.AccessibilityTitle = GettextCatalog.GetString("Search Toolbox");
            filterEntry.AccessibilityHelp  = GettextCatalog.GetString("Enter a term to search for it in the toolbox");
            filterEntry.Activated         += FilterTextChanged;
            filterEntry.Focused           += FilterEntry_Focused;

            horizontalStackView.AddArrangedSubview(filterEntry);
            AddWidgetToFocusChain(filterEntry);

            filterEntry.SetContentCompressionResistancePriority((int)NSLayoutPriority.DefaultLow, NSLayoutConstraintOrientation.Horizontal);
            filterEntry.SetContentHuggingPriorityForOrientation((int)NSLayoutPriority.DefaultLow, NSLayoutConstraintOrientation.Horizontal);

            catToggleButton       = new NativeViews.ToggleButton();
            catToggleButton.Image = groupByCategoryImage.ToNSImage();
            catToggleButton.AccessibilityTitle = GettextCatalog.GetString("Show categories");
            catToggleButton.ToolTip            = GettextCatalog.GetString("Show categories");
            catToggleButton.AccessibilityHelp  = GettextCatalog.GetString("Toggle to show categories");
            catToggleButton.Activated         += ToggleCategorisation;
            catToggleButton.Focused           += CatToggleButton_Focused;

            horizontalStackView.AddArrangedSubview(catToggleButton);
            AddWidgetToFocusChain(catToggleButton);

            catToggleButton.SetContentCompressionResistancePriority((int)NSLayoutPriority.DefaultHigh, NSLayoutConstraintOrientation.Horizontal);
            catToggleButton.SetContentHuggingPriorityForOrientation((int)NSLayoutPriority.DefaultHigh, NSLayoutConstraintOrientation.Horizontal);

            compactModeToggleButton                    = new NativeViews.ToggleButton();
            compactModeToggleButton.Image              = compactImage.ToNSImage();
            compactModeToggleButton.ToolTip            = GettextCatalog.GetString("Use compact display");
            compactModeToggleButton.AccessibilityTitle = GettextCatalog.GetString("Compact Layout");
            compactModeToggleButton.AccessibilityHelp  = GettextCatalog.GetString("Toggle for toolbox to use compact layout");
            compactModeToggleButton.Activated         += ToggleCompactMode;
            compactModeToggleButton.Focused           += CompactModeToggleButton_Focused;

            horizontalStackView.AddArrangedSubview(compactModeToggleButton);
            AddWidgetToFocusChain(compactModeToggleButton);

            compactModeToggleButton.SetContentCompressionResistancePriority((int)NSLayoutPriority.DefaultHigh, NSLayoutConstraintOrientation.Horizontal);
            compactModeToggleButton.SetContentHuggingPriorityForOrientation((int)NSLayoutPriority.DefaultHigh, NSLayoutConstraintOrientation.Horizontal);

            toolboxAddButton       = new NativeViews.ClickedButton();
            toolboxAddButton.Image = addImage.ToNSImage();
            toolboxAddButton.AccessibilityTitle = GettextCatalog.GetString("Add toolbox items");
            toolboxAddButton.AccessibilityHelp  = GettextCatalog.GetString("Add toolbox items");
            toolboxAddButton.ToolTip            = GettextCatalog.GetString("Add toolbox items");
            toolboxAddButton.Activated         += ToolboxAddButton_Clicked;
            toolboxAddButton.Focused           += ToolboxAddButton_Focused;

            horizontalStackView.AddArrangedSubview(toolboxAddButton);
            AddWidgetToFocusChain(toolboxAddButton);

            toolboxAddButton.SetContentCompressionResistancePriority((int)NSLayoutPriority.DefaultHigh, NSLayoutConstraintOrientation.Horizontal);
            toolboxAddButton.SetContentHuggingPriorityForOrientation((int)NSLayoutPriority.DefaultHigh, NSLayoutConstraintOrientation.Horizontal);

            #endregion

            toolboxWidget = new MacToolboxWidget(container)
            {
                AccessibilityTitle = GettextCatalog.GetString("Toolbox Toolbar"),
            };
            AddWidgetToFocusChain(toolboxWidget);

            var scrollView = new NSScrollView()
            {
                HasVerticalScroller   = true,
                HasHorizontalScroller = false,
                TranslatesAutoresizingMaskIntoConstraints = false
            };
            scrollView.WantsLayer   = true;
            scrollView.DocumentView = toolboxWidget;
            AddArrangedSubview(scrollView);

            //update view when toolbox service updated
            toolboxService.ToolboxContentsChanged += ToolboxService_ToolboxContentsChanged;
            toolboxService.ToolboxConsumerChanged += ToolboxService_ToolboxConsumerChanged;

            filterEntry.Changed += FilterEntry_Changed;

            toolboxWidget.DragBegin            += ToolboxWidget_DragBegin;
            toolboxWidget.MouseDownActivated   += ToolboxWidget_MouseDownActivated;
            toolboxWidget.ActivateSelectedItem += ToolboxWidget_ActivateSelectedItem;
            toolboxWidget.MenuOpened           += ToolboxWidget_MenuOpened;
            toolboxWidget.RegionCollapsed      += FilterTextChanged;

            //set initial state
            toolboxWidget.ShowCategories   = catToggleButton.Active = true;
            compactModeToggleButton.Active = MonoDevelop.Core.PropertyService.Get("ToolboxIsInCompactMode", false);
            toolboxWidget.IsListMode       = !compactModeToggleButton.Active;
        }
        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);
        }
Пример #27
0
        public PreviewPane(NSImage severityIcon, string id, string title, string description, Uri helpLink, string helpLinkToolTipText, IReadOnlyList <object> previewContent, bool logIdVerbatimInTelemetry, Guid?optionPageGuid = null)
        {
            _differenceViewerPreview = (DifferenceViewerPreview)previewContent[0];
            var view = ((ICocoaDifferenceViewer)_differenceViewerPreview.Viewer).VisualElement;

            var originalSize = view.Frame.Size;

            this.TranslatesAutoresizingMaskIntoConstraints = false;

            // === Title ===
            // Title is in a stack view to help with padding
            var titlePlaceholder = new NSStackView()
            {
                Orientation = NSUserInterfaceLayoutOrientation.Vertical,
                EdgeInsets  = new NSEdgeInsets(5, 0, 5, 0),
                Alignment   = NSLayoutAttribute.Leading,
                TranslatesAutoresizingMaskIntoConstraints = false
            };

            // TODO: missing icon
            this.titleField = new NSTextField()
            {
                Editable        = false,
                Bordered        = false,
                BackgroundColor = NSColor.ControlBackground,
                DrawsBackground = false,
            };

            titlePlaceholder.AddArrangedSubview(titleField);
            AddSubview(titlePlaceholder);

            // === Preview View ===
            // This is the actual view, that shows the diff
            view.TranslatesAutoresizingMaskIntoConstraints = false;
            NSLayoutConstraint.Create(view, NSLayoutAttribute.Width, NSLayoutRelation.GreaterThanOrEqual, 1, originalSize.Width).Active   = true;
            NSLayoutConstraint.Create(view, NSLayoutAttribute.Height, NSLayoutRelation.GreaterThanOrEqual, 1, originalSize.Height).Active = true;
            view.Subviews[0].TranslatesAutoresizingMaskIntoConstraints = false;
            view.WantsLayer = true;

            AddSubview(view);

            // === Constraints ===
            var constraints = new NSLayoutConstraint[]
            {
                // Title
                NSLayoutConstraint.Create(titlePlaceholder, NSLayoutAttribute.Top, NSLayoutRelation.Equal, this, NSLayoutAttribute.Top, 1, 0),
                NSLayoutConstraint.Create(titlePlaceholder, NSLayoutAttribute.Leading, NSLayoutRelation.Equal, this, NSLayoutAttribute.Leading, 1, 0),
                NSLayoutConstraint.Create(titlePlaceholder, NSLayoutAttribute.Trailing, NSLayoutRelation.Equal, this, NSLayoutAttribute.Trailing, 1, 0),

                // Preview View
                NSLayoutConstraint.Create(view, NSLayoutAttribute.Bottom, NSLayoutRelation.Equal, this, NSLayoutAttribute.Bottom, 1, 0),
                NSLayoutConstraint.Create(view, NSLayoutAttribute.Leading, NSLayoutRelation.Equal, this, NSLayoutAttribute.Leading, 1, 0),
                NSLayoutConstraint.Create(view, NSLayoutAttribute.Trailing, NSLayoutRelation.Equal, this, NSLayoutAttribute.Trailing, 1, 0),

                // subviews
                NSLayoutConstraint.Create(view.Subviews[0], NSLayoutAttribute.Top, NSLayoutRelation.Equal, view, NSLayoutAttribute.Top, 1, 0),
                NSLayoutConstraint.Create(view.Subviews[0], NSLayoutAttribute.Bottom, NSLayoutRelation.Equal, view, NSLayoutAttribute.Bottom, 1, 0),
                NSLayoutConstraint.Create(view.Subviews[0], NSLayoutAttribute.Left, NSLayoutRelation.Equal, view, NSLayoutAttribute.Left, 1, 0),
                NSLayoutConstraint.Create(view.Subviews[0], NSLayoutAttribute.Right, NSLayoutRelation.Equal, view, NSLayoutAttribute.Right, 1, 0),
            };

            if (GenerateAttributeString(id, title, helpLink, helpLinkToolTipText) is NSAttributedString attributedStringTitle)
            {
                this.titleField.AttributedStringValue = attributedStringTitle;
                // We do this separately, because the title sometimes isn't there (i.e. no diagnostics ID)
                // and we want the preview to stretch to the top
                NSLayoutConstraint.Create(view, NSLayoutAttribute.Top, NSLayoutRelation.Equal, titlePlaceholder, NSLayoutAttribute.Bottom, 1, 0).Active = true;
            }
            else
            {
                NSLayoutConstraint.Create(view, NSLayoutAttribute.Top, NSLayoutRelation.Equal, this, NSLayoutAttribute.Top, 1, 0).Active = true;
            }

            NSLayoutConstraint.ActivateConstraints(constraints);

            _differenceViewerPreview.Viewer.InlineView.TryMoveCaretToAndEnsureVisible(
                new Microsoft.VisualStudio.Text.SnapshotPoint(_differenceViewerPreview.Viewer.InlineView.TextSnapshot, 0));
        }
Пример #28
0
        static void Main(string[] args)
        {
            NSApplication.Init();
            NSApplication.SharedApplication.ActivationPolicy = NSApplicationActivationPolicy.Regular;

            var xPos       = NSScreen.MainScreen.Frame.Width / 2;  // NSWidth([[window screen] frame])/ 2 - NSWidth([window frame])/ 2;
            var yPos       = NSScreen.MainScreen.Frame.Height / 2; // NSHeight([[window screen] frame])/ 2 - NSHeight([window frame])/ 2;
            var mainWindow = new MacAccInspectorWindow(new CGRect(xPos, yPos, 300, 368), NSWindowStyle.Titled | NSWindowStyle.Resizable | NSWindowStyle.Closable, NSBackingStore.Buffered, false);

            var stackView = new NSStackView()
            {
                Orientation = NSUserInterfaceLayoutOrientation.Vertical
            };

            mainWindow.ContentView = stackView;
            stackView.AddArrangedSubview(new NSTextField {
                StringValue = "123"
            });

            stackView.AddArrangedSubview(new NSTextField {
                StringValue = "45"
            });
            stackView.AddArrangedSubview(new NSTextField {
                StringValue = "345"
            });
            var button = new NSButton {
                Title = "Press to show a message"
            };

            stackView.AddArrangedSubview(button);

            var hotizontalView = new NSStackView()
            {
                Orientation = NSUserInterfaceLayoutOrientation.Horizontal
            };

            hotizontalView.AddArrangedSubview(new NSTextField()
            {
                StringValue = "test"
            });

            stackView.AddArrangedSubview(hotizontalView);

            button.Activated += (sender, e) => {
                var alert = new NSAlert();
                alert.MessageText     = "You clicked the button!!!";
                alert.InformativeText = "Are you sure!?";
                alert.AddButton("OK!");
                alert.RunModal();
            };

            var button2 = new NSButton {
                Title = "Opens Localized text"
            };

            button2.Activated += (sender, e) => {
                var window = new NSWindow()
                {
                    StyleMask = NSWindowStyle.Titled | NSWindowStyle.Resizable | NSWindowStyle.Closable
                };
                var stack = NativeViewHelper.CreateHorizontalStackView();
                var label = NativeViewHelper.CreateLabel("hello");
                stack.AddArrangedSubview(label);
                window.ContentView = stack;
                window.WillClose  += (sender1, e1) =>
                {
                    window.Dispose();
                };
                window.MakeKeyAndOrderFront(mainWindow);
            };
            stackView.AddArrangedSubview(button2);
            button2.HeightAnchor.ConstraintEqualToConstant(100).Active = true;;

            mainWindow.Title = "Example Debug Xamarin.Mac";

            //mainWindow.MakeKeyWindow();
            mainWindow.MakeKeyAndOrderFront(null);
            NSApplication.SharedApplication.ActivateIgnoringOtherApps(true);
            NSApplication.SharedApplication.Run();
            //mainWindow.Dispose();
        }
Пример #29
0
        public MacAccessibilityWindow(CGRect frame) : base(frame, NSWindowStyle.Titled | NSWindowStyle.Resizable, NSBackingStore.Buffered, false)
        {
            ShowsToolbarButton        = false;
            MovableByWindowBackground = false;

            contentView = NativeViewHelper.CreateVerticalStackView(margin);
            ContentView = contentView;

            outlineAccessibilityView = new OutlineView();

            var outlineViewScrollView = new ScrollContainerView(outlineAccessibilityView);

            contentView.AddArrangedSubview(outlineViewScrollView);

            outlineAccessibilityView.SelectionNodeChanged += (s, e) => {
                if (outlineAccessibilityView.SelectedNode is NodeIssue nodeView)
                {
                    RaiseAccessibilityIssueSelected?.Invoke(this, nodeView.DetectedError?.View);
                }
            };

            outlineAccessibilityView.DoubleClick += (s, e) => {
                outlineAccessibilityView.ExpandItem(outlineAccessibilityView.SelectedNode, true);
            };

            outlineAccessibilityView.OutlineTableColumn.Title = "Issues";

            var service = AccessibilityService.Current;

            service.ScanFinished += (s, window) => {
                var nodeBase = new NodeIssue("Issues");
                foreach (var error in service.DetectedErrors)
                {
                    nodeBase.AddChild(new NodeIssue(error));
                }
                outlineAccessibilityView.SetData(nodeBase);
            };

            outlineViewScrollView.LeftAnchor.ConstraintEqualToAnchor(contentView.LeftAnchor, 0).Active   = true;
            outlineViewScrollView.RightAnchor.ConstraintEqualToAnchor(contentView.RightAnchor, 0).Active = true;
            //outlineViewScrollView.HeightAnchor.ConstraintGreaterThanOrEqualToConstant (200).Active = true;

            var buttonContainer = NativeViewHelper.CreateHorizontalStackView();

            buttonContainer.Alignment    = NSLayoutAttribute.CenterY;
            buttonContainer.Distribution = NSStackViewDistribution.Fill;
            contentView.AddArrangedSubview(buttonContainer);

            var runAuditButton = NativeViewHelper.CreateButton("Run Audit");

            buttonContainer.AddArrangedSubview(runAuditButton);
            runAuditButton.Activated += (sender, e) => AuditRequested?.Invoke(this, EventArgs.Empty);

            runAuditButton.WidthAnchor.ConstraintEqualToConstant(150).Active = true;
            runAuditButton.HeightAnchor.ConstraintEqualToConstant(40).Active = true;

            var showHideErrorsButton = NativeViewHelper.CreateButton("Show/Hide Errors");

            buttonContainer.AddArrangedSubview(showHideErrorsButton);

            contentView.AddArrangedSubview(new NSView()
            {
                TranslatesAutoresizingMaskIntoConstraints = false
            });
            showHideErrorsButton.Activated += (sender, e) => ShowErrorsRequested?.Invoke(this, EventArgs.Empty);
            showHideErrorsButton.WidthAnchor.ConstraintEqualToConstant(150).Active = true;
            showHideErrorsButton.HeightAnchor.ConstraintEqualToConstant(40).Active = true;

            errorLabel = NativeViewHelper.CreateLabel("");
            buttonContainer.AddArrangedSubview(errorLabel);

            var accessibilityService = AccessibilityService.Current;

            accessibilityService.ScanFinished += (s, e) => {
                errorLabel.StringValue = string.Format("{0} errors found.", accessibilityService.IssuesFound);
            };

            buttonContainer.LeftAnchor.ConstraintEqualToAnchor(contentView.LeftAnchor, 10).Active   = true;
            buttonContainer.RightAnchor.ConstraintEqualToAnchor(contentView.RightAnchor, 10).Active = true;
            buttonContainer.HeightAnchor.ConstraintEqualToConstant(40).Active = true;
        }
Пример #30
0
        public override bool PrepareSavePanel(NSSavePanel savePanel)
        {
            workbookSaveOperation = Session.CreateWorkbookSaveOperation();
            if (workbookSaveOperation.SupportedOptions == WorkbookSaveOptions.None)
            {
                return(true);
            }

            var stackView = new NSStackView {
                Orientation = NSUserInterfaceLayoutOrientation.Vertical,
                Spacing     = 8,
                EdgeInsets  = new NSEdgeInsets(12, 12, 12, 12)
            };

            Action <NSView> addRow = row => {
                stackView.AddView(row, NSStackViewGravity.Top);
                stackView.AddConstraint(NSLayoutConstraint.Create(
                                            row,
                                            NSLayoutAttribute.Width,
                                            NSLayoutRelation.Equal,
                                            stackView,
                                            NSLayoutAttribute.Width,
                                            1,
                                            0));
            };

            if (workbookSaveOperation.SupportedOptions.HasFlag(WorkbookSaveOptions.Archive))
            {
                addRow(CreateRow(
                           Catalog.GetString("Workbook Format:"),
                           new [] {
                    Catalog.GetString("Package Directory"),
                    Catalog.GetString("Archive")
                },
                           workbookSaveOperation.Options.HasFlag(WorkbookSaveOptions.Archive) ? 1 : 0,
                           index => {
                    switch (index)
                    {
                    case 0:
                        workbookSaveOperation.Options &= ~WorkbookSaveOptions.Archive;
                        break;

                    case 1:
                        workbookSaveOperation.Options |= WorkbookSaveOptions.Archive;
                        break;

                    default:
                        throw new IndexOutOfRangeException();
                    }
                }));
            }

            #if false
            // stubbed UI for signing is unused for now
            if (workbookSaveOperation.SupportedOptions.HasFlag(WorkbookSaveOptions.Sign))
            {
                addRow(CreateRow(
                           Catalog.GetString("Signing Key:"),
                           new [] {
                    Catalog.GetString("None")
                },
                           0,
                           index => { }));
            }
            #endif

            savePanel.AccessoryView = stackView;

            return(true);
        }