Esempio n. 1
0
        public void Initialize()
        {
            toolbarView.RegisterClassForItem(typeof(MacInspectorToolbarHeaderCollectionViewItem), MacInspectorToolbarHeaderCollectionViewItem.Name);
            toolbarView.RegisterClassForItem(typeof(MacInspectorToolbarCollectionViewItem), MacInspectorToolbarCollectionViewItem.Name);
            toolbarView.RegisterClassForItem(typeof(MacInspectorToolbarImageCollectionViewItem), MacInspectorToolbarImageCollectionViewItem.Name);

            var toolbarItem = new CollectionHeaderItem()
            {
                Label = "Main"
            };

            toolbarItem.Items.Add(new CollectionItem()
            {
                TypeOfView = ToolbarView.DatePicker, Image = inspectorDelegate.GetImageResource("view_dateView.png"), Label = "Date Picker", Description = "Provides for visually display and editing an NSDate instance."
            });
            toolbarItem.Items.Add(new CollectionItem()
            {
                TypeOfView = ToolbarView.WrappingLabel, Image = inspectorDelegate.GetImageResource("view_multiline.png"), Label = "Wrapping Label", Description = "Display static text that line wraps as needed."
            });
            toolbarItem.Items.Add(new CollectionItem()
            {
                TypeOfView = ToolbarView.ScrollableTextView, Image = inspectorDelegate.GetImageResource("view_scrollable.png"), Label = "Scrollable Text View", Description = "A text view enclosed in a scroll view. This configuration is suitable for UI elements typically used in inspectors."
            });
            toolbarItem.Items.Add(new CollectionItem()
            {
                TypeOfView = ToolbarView.TextField, Image = inspectorDelegate.GetImageResource("view_textView.png"), Label = "Text Field", Description = "Displays editable text"
            });

            toolbarItem.Items.Add(new CollectionItem()
            {
                TypeOfView = ToolbarView.PushButton, Image = inspectorDelegate.GetImageResource("view_button.png"), Label = "Push Button", Description = "For use un window content areas. Use text, not images."
            });

            toolbarItem.Items.Add(new CollectionItem()
            {
                TypeOfView = ToolbarView.Label, Image = inspectorDelegate.GetImageResource("view_label.png"), Label = "Label", Description = "Display a static text"
            });
            toolbarItem.Items.Add(new CollectionItem()
            {
                TypeOfView = ToolbarView.Search, Image = inspectorDelegate.GetImageResource("view_search.png"), Label = "Search Field", Description = "A text field that is optimized for performing text-based searches"
            });
            toolbarItem.Items.Add(new CollectionItem()
            {
                TypeOfView = ToolbarView.ComboBox, Image = inspectorDelegate.GetImageResource("view_combo.png"), Label = "Combo Box", Description = "Allows you to either enter text directly (as you would with NSTextField) or click the attached arrow at the right of the combo box to select from a displayed pop-up"
            });

            toolbarItem.Items.Add(new CollectionItem()
            {
                TypeOfView = ToolbarView.ImageBox, Image = inspectorDelegate.GetImageResource("view_image.png"), Label = "Image Button", Description = "For use in window content areas or toolbar"
            });

            toolbarData.Add(toolbarItem);

            Search();
        }
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 });
        }