public ErrorMessageView(IEnumerable errors)
        {
            if (errors == null)
            {
                throw new ArgumentNullException("errors");
            }

            ErrorMessages = new NSTextField {
                TranslatesAutoresizingMaskIntoConstraints = false,
                BackgroundColor = NSColor.Clear,
                Editable        = false,
            };

            foreach (var error in errors)
            {
                ErrorMessages.StringValue += error + "\n";
            }

            AddSubview(ErrorMessages);

            this.DoConstraints(new[] {
                ErrorMessages.ConstraintTo(this, (s, c) => s.Width == c.Width - 5),
                ErrorMessages.ConstraintTo(this, (s, c) => s.Height == c.Height - 5),
            });
        }
        public StringEditorControl()
        {
            StringEditor = new NSTextField {
                BackgroundColor = NSColor.Clear,
                ControlSize     = NSControlSize.Small,
                Font            = NSFont.FromFontName(DefaultFontName, DefaultFontSize),
                StringValue     = string.Empty,
                TranslatesAutoresizingMaskIntoConstraints = false,
            };

            // update the value on keypress
            StringEditor.Changed += (sender, e) => {
                ViewModel.Value = StringEditor.StringValue;
            };
            AddSubview(StringEditor);

            this.DoConstraints(new[] {
                StringEditor.ConstraintTo(this, (s, c) => s.Width == c.Width - 34),
                StringEditor.ConstraintTo(this, (s, c) => s.Height == DefaultControlHeight - 3),
                StringEditor.ConstraintTo(this, (s, c) => s.Left == s.Left + 4),
                StringEditor.ConstraintTo(this, (s, c) => s.Top == s.Top + 1),
            });

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