private void UpdateGui()
        {
            if (!NSThread.IsMain)
            {
                InvokeOnMainThread(UpdateGui);
                return;
            }

            nint oldSelectedRow = GuiTableEmails.SelectedRow;

            if (oldSelectedRow < 0)
            {
                oldSelectedRow = 0;
            }

            EmailTableDelegate oldDelegate = GuiTableEmails.Delegate as EmailTableDelegate;

            if (oldDelegate != null)
            {
                oldDelegate.OnSelectionChanged -= SetEnableButtons;
            }

            EmailsTableDataSource dataSource = new EmailsTableDataSource(__Model);

            GuiTableEmails.DataSource = dataSource;
            EmailTableDelegate tableDelegate = new EmailTableDelegate(dataSource);

            GuiTableEmails.Delegate = tableDelegate;

            GuiLabelEmailsCount.StringValue = string.Format(LocalizedStrings.Instance.LocalizedString("Label_PrivateEmail_AmountOfEmailsTitle_PARAMETRIZED"), __Model.PrivateEmails.Count);

            //restore selection
            if (__Model.PrivateEmails.Count > 0 && oldSelectedRow >= 0)
            {
                if (oldSelectedRow < __Model.PrivateEmails.Count)
                {
                    GuiTableEmails.SelectRow(oldSelectedRow, false);
                }
                else
                {
                    GuiTableEmails.SelectRow(__Model.PrivateEmails.Count - 1, false);
                }
            }

            tableDelegate.OnSelectionChanged += SetEnableButtons;
            SetEnableButtons();
        }
 public EmailTableDelegate(EmailsTableDataSource datasource)
 {
     this.DataSource = datasource;
 }