public void OnAttributeUpdate(object sender, EventArgs e)
 {
     if (AttributeTableView.SelectedRows != null && (int)AttributeTableView.SelectedRows.Count > 0)
     {
         var row = (int)AttributeTableView.SelectedRows.FirstIndex;
         var dto = RelyingPartyDto.AttributeConsumerServices [row];
         NSApplication.SharedApplication.StopModal();
         var defaultExists = RelyingPartyDto.AttributeConsumerServices.Exists(x => x.IsDefault);
         var form          = new AddNewAttributeConsumerServiceController()
         {
             DefaultSet = defaultExists, AttributeConsumerServiceDto = dto
         };
         NSApplication.SharedApplication.RunModalForWindow(form.Window);
         if (form.IsUpdated != null)
         {
             RelyingPartyDto.AttributeConsumerServices.RemoveAt(row);
             RelyingPartyDto.AttributeConsumerServices.Add(form.AttributeConsumerServiceDto);
             var datasource = new AttributeConsumerServiceDataSource {
                 Entries = RelyingPartyDto.AttributeConsumerServices
             };
             AttributeTableView.DataSource = datasource;
             AttributeTableView.ReloadData();
         }
     }
 }
        private void InitializeAttributeConsumerServices()
        {
            foreach (NSTableColumn column in AttributeTableView.TableColumns())
            {
                AttributeTableView.RemoveColumn(column);
            }
            AttributeTableView.Delegate = new TableDelegate();
            var listView = new AttributeConsumerServiceDataSource {
                Entries = RelyingPartyDto.AttributeConsumerServices
            };
            var columnNames = new List <ColumnOptions> {
                new ColumnOptions {
                    Id = "Name", DisplayName = "Name", DisplayOrder = 1, Width = 80
                },
                new ColumnOptions {
                    Id = "Index", DisplayName = "Index", DisplayOrder = 2, Width = 80
                },
                new ColumnOptions {
                    Id = "IsDefault", DisplayName = "Default", DisplayOrder = 3, Width = 80
                }
            };
            var columns = ListViewHelper.ToNSTableColumns(columnNames);

            foreach (var column in columns)
            {
                AttributeTableView.AddColumn(column);
            }
            AttributeTableView.DataSource = listView;
            AttributeTableView.ReloadData();
        }
Пример #3
0
 private void InitializeAttributes()
 {
     AttributeTableView.Delegate   = new TableDelegate(this);
     AttributeTableView.DataSource = new AttributeDataSource {
         Entries = _attributes
     };
     AttributeTableView.ReloadData();
 }
Пример #4
0
 public void OnRemoveAttributeServices(object sender, EventArgs e)
 {
     if (AttributeTableView.SelectedRows != null && AttributeTableView.SelectedRows.Count > 0)
     {
         foreach (var row in AttributeTableView.SelectedRows)
         {
             RelyingPartyDto.AttributeConsumerServices.RemoveAt((int)row);
         }
         var datasource = new AttributeConsumerServiceDataSource {
             Entries = RelyingPartyDto.AttributeConsumerServices
         };
         AttributeTableView.DataSource = datasource;
         AttributeTableView.ReloadData();
     }
 }
        public void OnAddAttributeServices(object sender, EventArgs e)
        {
            NSApplication.SharedApplication.StopModal();
            var defaultExists = RelyingPartyDto.AttributeConsumerServices.Exists(x => x.IsDefault);
            var form          = new AddNewAttributeConsumerServiceController()
            {
                DefaultSet = defaultExists
            };

            NSApplication.SharedApplication.RunModalForWindow(form.Window);
            if (form.AttributeConsumerServiceDto != null)
            {
                RelyingPartyDto.AttributeConsumerServices.Add(form.AttributeConsumerServiceDto);
                var datasource = new AttributeConsumerServiceDataSource {
                    Entries = RelyingPartyDto.AttributeConsumerServices
                };
                AttributeTableView.DataSource = datasource;
                AttributeTableView.ReloadData();
            }
        }
        private void InitializeAttributes()
        {
//			foreach(NSTableColumn column in AttributeTableView.TableColumns())
//			{
//				AttributeTableView.RemoveColumn (column);
//			}

//			AttributeTableView.Delegate = new TableDelegate ();
//			var listView = new AttributeDataSource { Entries = _attributes };
//			var columnNames = new List<ColumnOptions> {
//				new ColumnOptions{ Id = "Name", DisplayName = "Name", DisplayOrder = 1, Width = 80 },
//				new ColumnOptions{ Id = "FriendlyName", DisplayName = "Friendly Name", DisplayOrder = 2, Width = 150 },
//				new ColumnOptions{ Id = "NameFormat", DisplayName = "Name Format", DisplayOrder = 3, Width = 150 }
//			};
//			var columns = ListViewHelper.ToNSTableColumns (columnNames);
//			foreach (var column in columns) {
//				AttributeTableView.AddColumn (column);
//			}
            AttributeTableView.Delegate   = new TableDelegate(this);
            AttributeTableView.DataSource = new AttributeDataSource {
                Entries = _attributes
            };
            AttributeTableView.ReloadData();
        }
Пример #7
0
        public override void AwakeFromNib()
        {
            base.AwakeFromNib();
            IsUpdated = false;
            //Events
            this.BtnAdd.Activated += (object sender, EventArgs e) => {
                if (string.IsNullOrEmpty(TxtName.StringValue))
                {
                    UIErrorHelper.ShowAlert("Name has invalid value", "Alert");
                }
                else if (string.IsNullOrEmpty(TxtIndex.StringValue))
                {
                    UIErrorHelper.ShowAlert("Index has invalid value", "Alert");
                }
                else if (ChDefault.StringValue == "1" && DefaultSet && (AttributeConsumerServiceDto != null && !AttributeConsumerServiceDto.IsDefault))
                {
                    UIErrorHelper.ShowAlert("Multiple attribute consumer services chosen as default", "Alert");
                }
                else
                {
                    AttributeConsumerServiceDto = new AttributeConsumerServiceDto
                    {
                        Name       = TxtName.StringValue,
                        Index      = TxtIndex.IntValue,
                        IsDefault  = ChDefault.StringValue == "1",
                        Attributes = (AttributeTableView.DataSource as AttributeDataSource).Entries
                    };
                    IsUpdated = true;
                    this.Close();
                    NSApplication.SharedApplication.StopModalWithCode(0);
                }
            };
            this.BtnAddAttribute.Activated += (object sender, EventArgs e) => {
                if (string.IsNullOrEmpty(TxtAttributeName.StringValue))
                {
                    UIErrorHelper.ShowAlert("Attribute name cannot be empty", "Alert");
                    return;
                }
                if (string.IsNullOrEmpty(TxtFriendlyName.StringValue))
                {
                    UIErrorHelper.ShowAlert("Attribute friendly name cannot be empty", "Alert");
                    return;
                }
                if (string.IsNullOrEmpty(TxtNameFormat.StringValue))
                {
                    UIErrorHelper.ShowAlert("Attribute name format cannot be empty", "Alert");
                    return;
                }
                var attributeDto = new AttributeDto
                {
                    Name         = TxtAttributeName.StringValue,
                    FriendlyName = TxtFriendlyName.StringValue,
                    NameFormat   = TxtNameFormat.StringValue
                };
                TxtAttributeName.StringValue = string.Empty;
                TxtFriendlyName.StringValue  = string.Empty;
                TxtNameFormat.StringValue    = string.Empty;
                _attributes.Add(attributeDto);
                AttributeTableView.DataSource = new AttributeDataSource {
                    Entries = _attributes
                };
                AttributeTableView.ReloadData();
            };
            this.BtnRemoveAttribute.Activated += (object sender, EventArgs e) => {
                if (AttributeTableView.SelectedRow > -1)
                {
                    _attributes.RemoveAt((int)AttributeTableView.SelectedRow);
                    AttributeTableView.DataSource = new AttributeDataSource {
                        Entries = _attributes
                    };
                    AttributeTableView.ReloadData();
                }
            };
            this.BtnClose.Activated += (object sender, EventArgs e) => {
                this.Close();
                NSApplication.SharedApplication.StopModalWithCode(0);
            };

            if (AttributeConsumerServiceDto != null)
            {
                TxtName.StringValue   = AttributeConsumerServiceDto.Name;
                _attributes           = AttributeConsumerServiceDto.Attributes;
                ChDefault.StringValue = AttributeConsumerServiceDto.IsDefault ? "1" : "0";
                TxtIndex.IntValue     = AttributeConsumerServiceDto.Index;
            }
            InitializeAttributes();
        }