Esempio n. 1
0
        NSView Getview(ToolbarView e)
        {
            switch (e)
            {
            case ToolbarView.ComboBox:
                return(new NSComboBox());

            case ToolbarView.DatePicker:
                return(new NSDatePicker());

            case ToolbarView.ImageBox:
                return(new NSImageView());

            case ToolbarView.Label:
                return(NativeViewHelper.CreateLabel("Label"));

            case ToolbarView.WrappingLabel:
                var label = NativeViewHelper.CreateLabel("Label");
                label.SetContentCompressionResistancePriority(250, NSLayoutConstraintOrientation.Horizontal);
                label.UsesSingleLineMode = false;
                label.LineBreakMode      = NSLineBreakMode.ByWordWrapping;
                return(label);

            case ToolbarView.PushButton:
                return(new NSButton()
                {
                    Title = "Button"
                });

            case ToolbarView.Search:
                return(new NSSearchField());
            }
            return(new NSView());
        }
Esempio n. 2
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);
        }
Esempio n. 3
0
        public InspectorWindow(IInspectDelegate inspectorDelegate, CGRect frame) : base(frame, NSWindowStyle.Titled | NSWindowStyle.Resizable, NSBackingStore.Buffered, false)
        {
            this.inspectorDelegate    = inspectorDelegate;
            ShowsToolbarButton        = false;
            MovableByWindowBackground = false;

            propertyEditorPanel = new PropertyEditorPanel();

            editorProvider = new PropertyEditorProvider();

            propertyEditorPanel.TargetPlatform = new TargetPlatform(editorProvider)
            {
                SupportsCustomExpressions = true,
                SupportsMaterialDesign    = true,
            };

            var currentThemeStyle = NSUserDefaults.StandardUserDefaults.StringForKey("AppleInterfaceStyle") ?? "Light";

            PropertyEditorPanel.ThemeManager.Theme = currentThemeStyle == "Dark" ? PropertyEditorTheme.Dark : PropertyEditorTheme.Light;

            contentView = ContentView;

            var stackView = NativeViewHelper.CreateVerticalStackView(margin);

            contentView.AddSubview(stackView);

            stackView.LeftAnchor.ConstraintEqualToAnchor(contentView.LeftAnchor, margin).Active    = true;
            stackView.RightAnchor.ConstraintEqualToAnchor(contentView.RightAnchor, -margin).Active = true;
            stackView.TopAnchor.ConstraintEqualToAnchor(contentView.TopAnchor, margin).Active      = true;

            constraint        = stackView.HeightAnchor.ConstraintEqualToConstant(contentView.Frame.Height - margin * 2);
            constraint.Active = true;
            outlineView       = new OutlineView();
            var outlineViewScrollView = new ScrollContainerView(outlineView);

            outlineView.SelectionNodeChanged += (s, e) =>
            {
                if (outlineView.SelectedNode is NodeView nodeView)
                {
                    RaiseFirstResponder?.Invoke(this, nodeView.Wrapper);
                }
            };

            outlineView.KeyPress += (sender, e) =>
            {
                if (e == DeleteKey)
                {
                    if (outlineView.SelectedNode is NodeView nodeView)
                    {
                        RaiseDeleteItem?.Invoke(this, nodeView.Wrapper);
                    }
                }
            };

            //TOOLBAR
            var toolbarTab = new NSTabView()
            {
                TranslatesAutoresizingMaskIntoConstraints = false
            };
            var toolbarTabViewWrapper = new MacTabWrapper(toolbarTab);

            toolbarTab.WantsLayer            = true;
            toolbarTab.Layer.BackgroundColor = NSColor.Red.CGColor;

            stackView.AddArrangedSubview(toolbarTab);

            toolbarTab.LeftAnchor.ConstraintEqualToAnchor(contentView.LeftAnchor, margin).Active    = true;
            toolbarTab.RightAnchor.ConstraintEqualToAnchor(contentView.RightAnchor, -margin).Active = true;
            toolbarTab.TopAnchor.ConstraintEqualToAnchor(contentView.TopAnchor, margin).Active      = true;
            toolbarTab.HeightAnchor.ConstraintEqualToConstant(ScrollViewSize).Active = true;

            /////////////////

            var toolbarTabItem = new NSTabViewItem();

            toolbarTabItem.Label = "Toolbar";

            var toolbarStackView = NativeViewHelper.CreateVerticalStackView();

            toolbarStackView.TranslatesAutoresizingMaskIntoConstraints = true;
            var toolbarHorizontalStackView = NativeViewHelper.CreateHorizontalStackView();

            toolbarHorizontalStackView.TranslatesAutoresizingMaskIntoConstraints = true;

            toolbarSearchTextField          = new NSSearchField();
            toolbarSearchTextField.Changed += (object sender, EventArgs e) =>
            {
                Search();
            };

            toolbarHorizontalStackView.AddArrangedSubview(toolbarSearchTextField);

            var compactModeToggleButton = new ToggleButton();

            compactModeToggleButton.TranslatesAutoresizingMaskIntoConstraints = true;
            compactModeToggleButton.Image   = inspectorDelegate.GetImageResource("compact-display-16.png").NativeObject as NSImage;
            compactModeToggleButton.ToolTip = "Use compact display";
            toolbarHorizontalStackView.AddArrangedSubview(compactModeToggleButton);

            toolbarStackView.AddArrangedSubview(toolbarHorizontalStackView);

            toolbarView = new MacInspectorToolbarView();
            var toolbarViewScrollView = new ScrollContainerView(toolbarView);

            toolbarStackView.AddArrangedSubview(toolbarViewScrollView);

            toolbarTabItem.View = toolbarStackView;
            toolbarView.ActivateSelectedItem += (sender, e) =>
            {
                RaiseInsertItem?.Invoke(this, toolbarView.SelectedItem.TypeOfView);
            };

            var outlineTabItem = new NSTabViewItem();

            outlineTabItem.Label = "View Hierarchy";
            outlineTabItem.View  = outlineViewScrollView;

            toolbarTab.Add(outlineTabItem);
            toolbarTab.Add(toolbarTabItem);

            foreach (var module in InspectorContext.Current.Modules)
            {
                if (!module.IsEnabled)
                {
                    continue;
                }
                module.Load(this, toolbarTabViewWrapper);
            }

            //===================

            //Method list view
            methodListView = new MethodListView();
            methodListView.AddColumn(new NSTableColumn("col")
            {
                Title = "Methods"
            });
            methodListView.DoubleClick += MethodListView_DoubleClick;

            scrollView = new ScrollContainerView(methodListView);

            var titleContainter = NativeViewHelper.CreateHorizontalStackView();

            //titleContainter.WantsLayer = true;
            //titleContainter.Layer.BackgroundColor = NSColor.Gray.CGColor;

            methodSearchView = new NSSearchField()
            {
                TranslatesAutoresizingMaskIntoConstraints = false
            };
            titleContainter.AddArrangedSubview(methodSearchView);
            methodSearchView.WidthAnchor.ConstraintEqualToConstant(180).Active = true;

            IImageWrapper  invokeImage  = inspectorDelegate.GetImageResource("execute-16.png");
            IButtonWrapper invokeButton = inspectorDelegate.GetImageButton(invokeImage);

            invokeButton.SetTooltip("Invoke Method!");
            invokeButton.SetWidth(ButtonWidth);

            titleContainter.AddArrangedSubview((NSView)invokeButton.NativeObject);
            invokeButton.Pressed += (s, e) => InvokeSelectedView();

            titleContainter.AddArrangedSubview(NativeViewHelper.CreateLabel("Result: "));

            resultMessage = NativeViewHelper.CreateLabel("");
            resultMessage.LineBreakMode = NSLineBreakMode.ByWordWrapping;

            titleContainter.AddArrangedSubview(resultMessage);

            var methodStackPanel = NativeViewHelper.CreateVerticalStackView();

            methodStackPanel.AddArrangedSubview(titleContainter);
            titleContainter.LeftAnchor.ConstraintEqualToAnchor(methodStackPanel.LeftAnchor, 0).Active   = true;
            titleContainter.RightAnchor.ConstraintEqualToAnchor(methodStackPanel.RightAnchor, 0).Active = true;

            methodStackPanel.AddArrangedSubview(scrollView);
            /////

            var tabPropertyPanel = new NSTabViewItem();

            tabPropertyPanel.View  = propertyEditorPanel;
            tabPropertyPanel.Label = "Properties";

            var tabMethod = new NSTabViewItem();

            tabMethod.View.AddSubview(methodStackPanel);
            methodStackPanel.LeftAnchor.ConstraintEqualToAnchor(tabMethod.View.LeftAnchor, 0).Active     = true;
            methodStackPanel.RightAnchor.ConstraintEqualToAnchor(tabMethod.View.RightAnchor, 0).Active   = true;
            methodStackPanel.TopAnchor.ConstraintEqualToAnchor(tabMethod.View.TopAnchor, 0).Active       = true;
            methodStackPanel.BottomAnchor.ConstraintEqualToAnchor(tabMethod.View.BottomAnchor, 0).Active = true;

            tabMethod.Label = "Methods";

            tabView = new NSTabView()
            {
                TranslatesAutoresizingMaskIntoConstraints = false
            };
            tabView.Add(tabPropertyPanel);
            tabView.Add(tabMethod);
            stackView.AddArrangedSubview(tabView as NSView);

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

            methodSearchView.Activated += (sender, e) =>
            {
                if (viewSelected != null)
                {
                    methodListView.SetObject(viewSelected.NativeObject, methodSearchView.StringValue);
                }
            };

            compactModeToggleButton.Activated += (sender, e) =>
            {
                toolbarView.ShowOnlyImages(!toolbarView.IsImageMode);
            };
        }
Esempio n. 4
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;
        }