public void WindowDidUpdate(NSNotification notification)
        {
            if (View != null &&
                View.Window != null &&
                View.Window.FirstResponder != null)
            {
                NSTextField tv = ApiUtils.GetFirstResponderTextField(View.Window);

                if (tv != null)
                {
                    if (m_prevResponder != tv &&
                        ApiUtils.IsTextFieldFirstResponder(View.Window, textFieldComputerName) &&
                        NSString.IsNullOrEmpty(textFieldComputerName.StringValue) &&
                        !NSString.IsNullOrEmpty(textFieldDisplayName.StringValue))
                    {
                        textFieldComputerName.StringValue = textFieldDisplayName.StringValue;
                    }

                    m_prevResponder = tv;
                }
                else
                {
                    m_prevResponder = View.Window.FirstResponder;
                }
            }
        }
        public override void LoadView()
        {
            this.SendMessageSuper(PropertyPageDummyMainControllerClass, "loadView");

            PropertyFields.Add(new RmPropertyPageColorChooserButtonField()
            {
                View                    = ColorButton,
                CanToggleEnabled        = true,
                AvailableInBulkEditMode = true
            });

            PropertyFields.Add(new RmPropertyPageIconButtonField()
            {
                View                    = IconButton,
                CanToggleEnabled        = true,
                AvailableInBulkEditMode = true
            });

            PropertyFields.Add(new RmPropertyPageDummyField()
            {
                View  = imageViewHeader,
                Image = Icon.Icon48
            });

            PropertyFields.Add(new RmPropertyPageDummyField()
            {
                LabelView = textFieldDescription,
                LabelText = "With a Remote Desktop connection you can connect to remote computers supporting RDP (Remote Desktop Protocol, Standard Port is 3389). You can change the port in the Advanced section.".TLL()
            });

            PropertyFields.Add(new RmPropertyPageStringTextField()
            {
                PropertyName             = "Name",
                View                     = textFieldDisplayName,
                PlaceholderText          = "Display Name".TL(),
                LabelView                = textFieldDisplayNameLabel,
                LabelText                = "Display Name:".TL(),
                FocusField               = true,
                DisabledIfDefaultSetting = true,
                CanToggleEnabled         = true,
                ValidationCallback       = (field) => {
                    string retVal = string.Empty;

                    if (!field.CurrentObject.IsDefaultSetting &&
                        !IsInBulkEditMode)
                    {
                        bool isDisplayNameRequired = !IsInBulkAddMode;
                        bool displayNameOk         = !NSString.IsNullOrEmpty(textFieldDisplayName.StringValue);

                        if (isDisplayNameRequired &&
                            !displayNameOk)
                        {
                            retVal = "The \"Display Name\" must not be empty.".TL();
                        }
                    }

                    return(retVal);
                },
                SaveSetObjectValueCallback = (field, obj) => {
                    if (!obj.IsDefaultSetting)
                    {
                        field.SetObjectValue(obj);
                    }
                }
            });

            PropertyFields.Add(new RmPropertyPageStringTextField()
            {
                PropertyName             = "URI",
                View                     = textFieldComputerName,
                PlaceholderText          = "Computer Name (IP/FQDN)".TL(),
                LabelView                = textFieldComputerNameLabel,
                LabelText                = "Computer Name:".TL(),
                DisabledIfDefaultSetting = true,
                CanToggleEnabled         = true,
                ToggleEnabledCallback    = (field, enabled) => {
                    field.View.CastTo <NSControl>().IsEnabled      = enabled;
                    field.LabelView.CastTo <NSControl>().IsEnabled = enabled;
                },
                ValidationCallback = (field) => {
                    string retVal = string.Empty;

                    if (!field.CurrentObject.IsDefaultSetting &&
                        !IsInBulkEditMode)
                    {
                        bool computerNameOk = !NSString.IsNullOrEmpty(textFieldComputerName.StringValue);

                        if (!computerNameOk)
                        {
                            retVal = "The \"Computer Name\" must not be empty.".TLL();
                        }
                    }

                    return(retVal);
                },
                LoadSetUiValueCallback = (field, obj) => {
                    buttonComputerNameEditor.IsEnabled = (!obj.IsDefaultSetting && EditMode == ObjectEditMode.EditMode_New);

                    field.SetUiValue(field.GetObjectValue(obj));
                },
                SaveSetObjectValueCallback = (field, obj) => {
                    if (!obj.IsDefaultSetting)
                    {
                        field.SetObjectValue(obj);
                    }
                }
            });

            PropertyFields.Add(new RmPropertyPageStringTextField()
            {
                PropertyName            = "Description",
                View                    = textFieldDescription,
                PlaceholderText         = "Description".TL(),
                LabelView               = textFieldDescriptionLabel,
                LabelText               = "Description:".TL(),
                CanToggleEnabled        = true,
                AvailableInBulkEditMode = true
            });

            PropertyFields.Add(new RmPropertyPageStringTextField()
            {
                PropertyName            = "PhysicalAddress",
                View                    = textFieldPhysicalAddress,
                PlaceholderText         = "Physical Address".TL(),
                LabelView               = textFieldPhysicalAddressLabel,
                LabelText               = "Physical Address:".TL(),
                CanToggleEnabled        = true,
                AvailableInBulkEditMode = true
            });

            PropertyFields.Add(new RmPropertyPageMetaDataField()
            {
                PropertyName = "MetaData",
                View         = metadataView
            });

            NSNotificationCenter.DefaultCenter.AddObserverSelectorNameObject(this, "windowDidUpdate:".ToSelector(), NSWindow.NSWindowDidUpdateNotification, this.View.Window);
        }