Esempio n. 1
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;
        }
Esempio n. 2
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. 3
0
        public MacToolbarWindow(IInspectDelegate inspectDelegate, CGRect frame) : base(frame, NSWindowStyle.Titled | NSWindowStyle.FullSizeContentView, NSBackingStore.Buffered, false)
        {
            this.inspectDelegate = inspectDelegate;
            //BackgroundColor = NSColor.Clear;
            IsOpaque = false;
            TitlebarAppearsTransparent = true;
            TitleVisibility            = NSWindowTitleVisibility.Hidden;
            ShowsToolbarButton         = false;
            MovableByWindowBackground  = false;

            NSStackView verticalStackView;

            ContentView = verticalStackView = NativeViewHelper.CreateVerticalStackView(MenuItemSeparation);

            stackView = NativeViewHelper.CreateHorizontalStackView(MenuItemSeparation);
            verticalStackView.AddArrangedSubview(stackView);

            stackView.LeftAnchor.ConstraintEqualToAnchor(verticalStackView.LeftAnchor, 10).Active   = true;
            stackView.RightAnchor.ConstraintEqualToAnchor(verticalStackView.RightAnchor, 10).Active = true;

            secondStackView = NativeViewHelper.CreateHorizontalStackView(MenuItemSeparation);
            verticalStackView.AddArrangedSubview(secondStackView);

            secondStackView.LeftAnchor.ConstraintEqualToAnchor(verticalStackView.LeftAnchor, 10).Active   = true;
            secondStackView.RightAnchor.ConstraintEqualToAnchor(verticalStackView.RightAnchor, 10).Active = true;

            //Visual issues view
            var actualImage       = (NSImage)inspectDelegate.GetImageResource("overlay-actual.png").NativeObject;
            var keyViewLoopButton = new ToggleButton()
            {
                Image = actualImage
            };

            keyViewLoopButton.ToolTip = "Shows current focused item";
            AddButton(keyViewLoopButton);
            keyViewLoopButton.Activated += (s, e) => {
                KeyViewLoop?.Invoke(this, keyViewLoopButton.IsToggled);
            };

            var previousImage         = (NSImage)inspectDelegate.GetImageResource("overlay-previous.png").NativeObject;
            var prevKeyViewLoopButton = new ToggleButton()
            {
                Image = previousImage
            };

            prevKeyViewLoopButton.ToolTip = "Shows previous view item";
            AddButton(prevKeyViewLoopButton);
            prevKeyViewLoopButton.Activated += (s, e) => {
                PreviousKeyViewLoop?.Invoke(this, prevKeyViewLoopButton.IsToggled);
            };

            var nextImage             = (NSImage)inspectDelegate.GetImageResource("overlay-next.png").NativeObject;
            var nextKeyViewLoopButton = new ToggleButton()
            {
                Image = nextImage
            };

            nextKeyViewLoopButton.ToolTip = "Shows next view item";
            AddButton(nextKeyViewLoopButton);
            nextKeyViewLoopButton.Activated += (s, e) => {
                NextKeyViewLoop?.Invoke(this, nextKeyViewLoopButton.IsToggled);
            };

            AddSeparator();

            var rescanImage = (NSImage)inspectDelegate.GetImageResource("rescan-16.png").NativeObject;

            toolkitButton = new ToggleButton {
                Image = rescanImage
            };
            toolkitButton.ToolTip = "Change beetween Toolkits";
            AddButton(toolkitButton);
            toolkitButton.Activated += ToolkitButton_Activated;;

            rescanSeparator = AddSeparator();

            var themeImage  = (NSImage)inspectDelegate.GetImageResource("style-16.png").NativeObject;
            var themeButton = new ToggleButton {
                Image = themeImage
            };

            themeButton.ToolTip = "Change Style Theme";
            AddButton(themeButton);
            themeButton.Activated += ThemeButton_Activated;

            AddSeparator();

            var deleteImage = (NSImage)inspectDelegate.GetImageResource("delete-16.png").NativeObject;

            deleteButton         = new ImageButton();
            deleteButton.Image   = deleteImage;
            deleteButton.ToolTip = "Delete selected item";
            AddButton(deleteButton);
            deleteButton.Activated += (s, e) =>
            {
                ItemDeleted?.Invoke(this, EventArgs.Empty);
            };

            var changeImg = (NSImage)inspectDelegate.GetImageResource("image-16.png").NativeObject;

            changeImage         = new ImageButton();
            changeImage.Image   = changeImg;
            changeImage.ToolTip = "Change image from selected item";
            AddButton(changeImage);

            changeImage.Activated += (s, e) =>
            {
                ItemImageChanged?.Invoke(this, EventArgs.Empty);
            };

            AddSeparator();

            languagesComboBox = new NSComboBox()
            {
                TranslatesAutoresizingMaskIntoConstraints = false
            };
            languagesComboBox.ToolTip = "Change font from selected item";

            cultureInfos = CultureInfo.GetCultures(CultureTypes.AllCultures);
            var culturesStr = new NSString[cultureInfos.Length];

            NSString selected = null;

            for (int i = 0; i < cultureInfos.Length; i++)
            {
                culturesStr[i] = new NSString(cultureInfos[i].DisplayName);
                if (i == 0 || cultureInfos[i] == Thread.CurrentThread.CurrentUICulture)
                {
                    selected = culturesStr[i];
                }
            }

            languagesComboBox.Add(culturesStr);
            stackView.AddArrangedSubview(languagesComboBox);

            languagesComboBox.Select(selected);

            languagesComboBox.Activated        += LanguagesComboBox_SelectionChanged;
            languagesComboBox.SelectionChanged += LanguagesComboBox_SelectionChanged;
            languagesComboBox.WidthAnchor.ConstraintLessThanOrEqualToConstant(220).Active = true;

            //FONTS

            fontsCombobox = new NSComboBox()
            {
                TranslatesAutoresizingMaskIntoConstraints = false
            };
            fontsCombobox.ToolTip = "Change font from selected item";
            fonts = NSFontManager.SharedFontManager.AvailableFonts
                    .Select(s => new NSString(s))
                    .ToArray();

            fontsCombobox.Add(fonts);
            fontsCombobox.WidthAnchor.ConstraintGreaterThanOrEqualToConstant(220).Active = true;

            fontSizeTextView = new NSTextField()
            {
                TranslatesAutoresizingMaskIntoConstraints = false
            };
            fontSizeTextView.ToolTip = "Change font size from selected item";
            fontSizeTextView.WidthAnchor.ConstraintEqualToConstant(40).Active = true;

            fontsCombobox.SelectionChanged += (s, e) => {
                OnFontChanged();
            };

            fontSizeTextView.Activated += (s, e) => {
                OnFontChanged();
            };

            endSpace = new NSView()
            {
                TranslatesAutoresizingMaskIntoConstraints = false
            };

            //stackView.AddArrangedSubview(new NSView() { TranslatesAutoresizingMaskIntoConstraints = false });
        }