public PanelHeaderEditorControl(IHostResourceProvider hostResources)
        {
            if (hostResources == null)
            {
                throw new ArgumentNullException(nameof(hostResources));
            }

            this.hostResources = hostResources;

            NSControlSize controlSize = NSControlSize.Small;

            TranslatesAutoresizingMaskIntoConstraints = false;

            this.propertyObjectName = new PropertyTextField {
                ControlSize       = controlSize,
                PlaceholderString = Properties.Resources.ObjectNamePlaceholder,
                TranslatesAutoresizingMaskIntoConstraints = false,
            };

            this.propertyObjectName.Activated += OnObjectNameEdited;

            AddSubview(this.propertyObjectName);

            this.typeDisplay = new UnfocusableTextField {
                TranslatesAutoresizingMaskIntoConstraints = false,
            };
            AddSubview(this.typeDisplay);

            this.objectNameLabel = new UnfocusableTextField {
                Alignment   = NSTextAlignment.Right,
                StringValue = Properties.Resources.Name + ":",
                TranslatesAutoresizingMaskIntoConstraints = false,
            };
            AddSubview(this.objectNameLabel);

            this.typeLabel = new UnfocusableTextField {
                Alignment   = NSTextAlignment.Right,
                StringValue = Properties.Resources.Type + ":",
                TranslatesAutoresizingMaskIntoConstraints = false,
            };
            AddSubview(this.typeLabel);

            this.propertyIcon = new NSImageView {
                ImageScaling = NSImageScale.AxesIndependently,
                TranslatesAutoresizingMaskIntoConstraints = false,
            };
            AddSubview(this.propertyIcon);

            this.AddConstraints(new[] {
                NSLayoutConstraint.Create(this.propertyIcon, NSLayoutAttribute.Width, NSLayoutRelation.Equal, 1, 32),
                NSLayoutConstraint.Create(this.propertyIcon, NSLayoutAttribute.Height, NSLayoutRelation.Equal, 1, 32),
                NSLayoutConstraint.Create(this.propertyIcon, NSLayoutAttribute.Top, NSLayoutRelation.Equal, this, NSLayoutAttribute.Top, 1, 5),
                NSLayoutConstraint.Create(this.propertyIcon, NSLayoutAttribute.Left, NSLayoutRelation.Equal, this, NSLayoutAttribute.Left, 1, 32),

                NSLayoutConstraint.Create(this.objectNameLabel, NSLayoutAttribute.Top, NSLayoutRelation.Equal, this, NSLayoutAttribute.Top, 1, 5),
                NSLayoutConstraint.Create(this.objectNameLabel, NSLayoutAttribute.Right, NSLayoutRelation.Equal, this, NSLayoutAttribute.Right, Mac.Layout.GoldenRatioLeft, 0),
                NSLayoutConstraint.Create(this.objectNameLabel, NSLayoutAttribute.Height, NSLayoutRelation.Equal, 1f, 20),

                NSLayoutConstraint.Create(this.propertyObjectName, NSLayoutAttribute.CenterY, NSLayoutRelation.Equal, this.objectNameLabel, NSLayoutAttribute.CenterY, 1, 0),
                NSLayoutConstraint.Create(this.propertyObjectName, NSLayoutAttribute.Left, NSLayoutRelation.Equal, this.objectNameLabel, NSLayoutAttribute.Right, 1, EditorContainer.LabelToControlSpacing),
                NSLayoutConstraint.Create(this.propertyObjectName, NSLayoutAttribute.Right, NSLayoutRelation.Equal, this, NSLayoutAttribute.Right, 1, -(EditorContainer.PropertyTotalWidth)),

                NSLayoutConstraint.Create(this.typeLabel, NSLayoutAttribute.Top, NSLayoutRelation.Equal, this.propertyObjectName, NSLayoutAttribute.Bottom, 1, 5),
                NSLayoutConstraint.Create(this.typeLabel, NSLayoutAttribute.Right, NSLayoutRelation.Equal, this, NSLayoutAttribute.Right, Mac.Layout.GoldenRatioLeft, 0),
                NSLayoutConstraint.Create(this.typeLabel, NSLayoutAttribute.Height, NSLayoutRelation.Equal, 1f, 20),

                NSLayoutConstraint.Create(this.typeDisplay, NSLayoutAttribute.Top, NSLayoutRelation.Equal, this.typeLabel, NSLayoutAttribute.Top, 1, 0),
                NSLayoutConstraint.Create(this.typeDisplay, NSLayoutAttribute.Width, NSLayoutRelation.Equal, this.propertyObjectName, NSLayoutAttribute.Width, 1, 0),
                NSLayoutConstraint.Create(this.typeDisplay, NSLayoutAttribute.Left, NSLayoutRelation.Equal, this.typeLabel, NSLayoutAttribute.Right, 1, EditorContainer.LabelToControlSpacing),
                NSLayoutConstraint.Create(this.typeDisplay, NSLayoutAttribute.Height, NSLayoutRelation.Equal, 1f, 20),
            });
        }
示例#2
0
        public static NSButton CreateButton(NSBezelStyle bezelStyle, NSFont font, string text, NSControlSize controlSize = NSControlSize.Regular, NSImage image = null, bool bordered = true)
        {
            var button = new NSButton
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                BezelStyle  = bezelStyle,
                Bordered    = bordered,
                ControlSize = controlSize,
                Font        = font ?? GetSystemFont(false),
                Title       = text
            };

            if (image != null)
            {
                button.Image = image;
            }

            return(button);
        }
示例#3
0
        private void Initialize(PropertyViewModel propertyViewModel)
        {
            this.ShowPreview = true;
            TranslatesAutoresizingMaskIntoConstraints = false;

            var FrameWidthThird = Frame.Width / 3;
            var FrameWidthHalf  = Frame.Width / 2;
            var FrameHeightHalf = Frame.Height / 2;

            NSControlSize controlSize = NSControlSize.Small;

            this.searchResources = new NSSearchField {
                ControlSize       = controlSize,
                Font              = NSFont.SystemFontOfSize(NSFont.SystemFontSizeForControlSize(NSControlSize.Small)),
                PlaceholderString = Properties.Resources.SearchResourcesTitle,
                TranslatesAutoresizingMaskIntoConstraints = false,
            };

            this.searchResources.Changed += OnSearchResourcesChanged;

            AddSubview(this.searchResources);

            var vmType            = propertyViewModel.GetType();
            var valuePropertyInfo = vmType.GetProperty("Value");
            var resourceValue     = valuePropertyInfo.GetValue(propertyViewModel);

            this.resourceSelectorPanel = new RequestResourcePanel(HostResources, new ResourceSelectorViewModel(propertyViewModel.TargetPlatform.ResourceProvider, propertyViewModel.Editors.Select(ed => ed.Target), propertyViewModel.Property), resourceValue);
            this.resourceSelectorPanel.ResourceSelected += (sender, e) => {
                propertyViewModel.Resource = this.resourceSelectorPanel.SelectedResource;
            };
            this.resourceSelectorPanel.DoubleClicked += (sender, e) => {
                PopOver.Close();
            };

            AddSubview(this.resourceSelectorPanel);

            segmentedControl = NSSegmentedControl.FromLabels(new string[] { Properties.Resources.AllResources, Properties.Resources.Local, Properties.Resources.Shared }, NSSegmentSwitchTracking.SelectOne, () => {
                //Switch Resource Types
                switch (this.segmentedControl.SelectedSegment)
                {
                case 0:
                    this.resourceSelectorPanel.ViewModel.ShowBothResourceTypes = true;
                    this.segmentedControl.SetImage(HostResources.GetNamedImage("pe-resource-editor-16"), 2);
                    break;

                case 1:
                    this.resourceSelectorPanel.ViewModel.ShowOnlyLocalResources = true;
                    this.segmentedControl.SetImage(HostResources.GetNamedImage("pe-resource-editor-16"), 2);
                    break;

                case 2:
                    this.resourceSelectorPanel.ViewModel.ShowOnlySystemResources = true;
                    this.segmentedControl.SetImage(HostResources.GetNamedImage("pe-resource-editor-16~sel"), 2);
                    break;
                }

                this.resourceSelectorPanel.ReloadData();
            });
            this.segmentedControl.SetImage(HostResources.GetNamedImage("pe-resource-editor-16"), 2);
            this.segmentedControl.Frame = new CGRect((FrameWidthThird - (segmentedControl.Bounds.Width) / 2), 5, (Frame.Width - (FrameWidthThird)) - 10, 24);
            this.segmentedControl.Font  = NSFont.SystemFontOfSize(NSFont.SystemFontSizeForControlSize(NSControlSize.Small));
            this.segmentedControl.TranslatesAutoresizingMaskIntoConstraints = false;
            this.segmentedControl.SetSelected(true, 0);
            this.resourceSelectorPanel.ViewModel.ShowBothResourceTypes = true;

            AddSubview(this.segmentedControl);

            this.showPreviewImage = new NSButton {
                Bordered    = false,
                ControlSize = controlSize,
                Image       = NSImage.ImageNamed(NSImageName.QuickLookTemplate),
                Title       = string.Empty,
                TranslatesAutoresizingMaskIntoConstraints = false,
            };

            this.showPreviewImage.Activated += (o, e) => {
                ShowPreview = !ShowPreview;
                RepositionControls();
            };

            AddSubview(this.showPreviewImage);

            OnSearchResourcesChanged(null, null);

            RepositionControls();
        }
        // Shared initialization code
        private void Initialize()
        {
            AutoresizingMask = NSViewResizingMask.WidthSizable | NSViewResizingMask.HeightSizable;

            NSControlSize controlSize = NSControlSize.Small;

            propertyFilter = new NSSearchField(new CGRect(10, Frame.Height - 25, 170, 24))
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                PlaceholderString = LocalizationResources.PropertyFilterLabel,
                ControlSize       = controlSize,
                Font = NSFont.FromFontName(PropertyEditorControl.DefaultFontName, PropertyEditorControl.DefaultFontSize),
            };
            AddSubview(propertyFilter);

            this.propertyArrangeModeLabel = new NSTextField(new CGRect(245, Frame.Height - 28, 150, 24))
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                BackgroundColor = NSColor.Clear,
                TextColor       = NSColor.Black,
                Editable        = false,
                Bezeled         = false,
                StringValue     = LocalizationResources.ArrangeByLabel,
                ControlSize     = controlSize,
            };

            propertyArrangeMode = new NSComboBox(new CGRect(320, Frame.Height - 25, 153, 24))
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
                Editable    = false,
                ControlSize = controlSize,
                Font        = NSFont.FromFontName(PropertyEditorControl.DefaultFontName, PropertyEditorControl.DefaultFontSize),
            };

            var enumValues = Enum.GetValues(typeof(PropertyArrangeMode));

            foreach (var item in enumValues)
            {
                propertyArrangeMode.Add(new NSString(item.ToString()));                    // TODO May need translating
            }
            propertyArrangeMode.SelectItem(0);

            if (IsArrangeEnabled)
            {
                AddSubview(this.propertyArrangeMode);
                AddSubview(this.propertyArrangeModeLabel);
            }

            // If either the Filter Mode or PropertySearchFilter Change Filter the Data
            propertyArrangeMode.SelectionChanged += OnArrageModeChanged;
            propertyFilter.Changed += OnPropertyFilterChanged;

            propertyTable = new FirstResponderOutlineView {
                RefusesFirstResponder   = true,
                AutoresizingMask        = NSViewResizingMask.WidthSizable,
                SelectionHighlightStyle = NSTableViewSelectionHighlightStyle.None,
                HeaderView = null,
            };

#if DESIGNER_DEBUG
            propertyTable.GridStyleMask = NSTableViewGridStyle.SolidHorizontalLine | NSTableViewGridStyle.SolidVerticalLine;
#endif

            NSTableColumn propertiesList = new NSTableColumn(PropertyListColId)
            {
                Title = LocalizationResources.PropertyColumnTitle
            };
            NSTableColumn propertyEditors = new NSTableColumn(PropertyEditorColId)
            {
                Title = LocalizationResources.ValueColumnTitle
            };
            propertiesList.Width  = 158;
            propertyEditors.Width = 250;
            propertyTable.AddColumn(propertiesList);
            propertyTable.AddColumn(propertyEditors);

            // Set OutlineTableColumn or the arrows showing children/expansion will not be drawn
            propertyTable.OutlineTableColumn = propertiesList;

            // create a table view and a scroll view
            var tableContainer = new NSScrollView(new CGRect(10, Frame.Height - 210, propertiesList.Width + propertyEditors.Width, Frame.Height - 55))
            {
                TranslatesAutoresizingMaskIntoConstraints = false,
            };

            // add the panel to the window
            tableContainer.DocumentView = propertyTable;
            AddSubview(tableContainer);

            this.DoConstraints(new NSLayoutConstraint[] {
                propertyFilter.ConstraintTo(this, (pf, c) => pf.Top == c.Top + 3),
                propertyFilter.ConstraintTo(this, (pf, c) => pf.Left == c.Left + 10),

                propertyArrangeModeLabel.ConstraintTo(this, (pl, c) => pl.Top == c.Top + 5),
                propertyArrangeModeLabel.ConstraintTo(propertyArrangeMode, (pl, pa) => pl.Left == pa.Left - 71),

                propertyArrangeMode.ConstraintTo(this, (pa, c) => pa.Top == c.Top + 4),
                propertyArrangeMode.ConstraintTo(this, (pa, c) => pa.Left == c.Left + 280),
                propertyArrangeMode.ConstraintTo(this, (pa, c) => pa.Width == c.Width - 291),

                tableContainer.ConstraintTo(this, (t, c) => t.Top == c.Top + 30),
                tableContainer.ConstraintTo(this, (t, c) => t.Width == c.Width - 20),
                tableContainer.ConstraintTo(this, (t, c) => t.Height == c.Height - 40),
            });

            ThemeManager.ThemeChanged += ThemeManager_ThemeChanged;

            UpdateTheme();
        }