本文整理汇总了C#中NSTableView类的典型用法代码示例。如果您正苦于以下问题:C# NSTableView类的具体用法?C# NSTableView怎么用?C# NSTableView使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
NSTableView类属于命名空间,在下文中一共展示了NSTableView类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AwakeFromNib
public override void AwakeFromNib ()
{
base.AwakeFromNib ();
this.BtnClose.Activated += (object sender, EventArgs e) => {
this.Close ();
NSApplication.SharedApplication.StopModalWithCode (0);
};
TableView = new NSTableView ();
TableView.Delegate = new TableDelegate ();
TableView.Frame = new CoreGraphics.CGRect (20, 20, 450, 450);
this.MainTableView.AddSubview (TableView);
IList<ComputerDto> computers = new List<ComputerDto> ();
ActionHelper.Execute (delegate() {
var auth = SnapInContext.Instance.AuthTokenManager.GetAuthToken (ServerDto.ServerName);
computers = SnapInContext.Instance.ServiceGateway.Server.GetComputers (ServerDto, auth.Token);
});
var listView = new ComputersDataSource { Entries = computers };
var columnNames = new List<ColumnOptions> {
new ColumnOptions{ Id = "Name", DisplayName = "Computer Name", DisplayOrder = 1, Width = 300 },
new ColumnOptions{ Id = "DomainController", DisplayName = "Domain Controller", DisplayOrder = 2, Width = 130 }
};
var columns = ListViewHelper.ToNSTableColumns (columnNames);
foreach (var column in columns) {
TableView.AddColumn (column);
}
TableView.DataSource = listView;
TableView.ReloadData ();
}
示例2: InitializeTable
private void InitializeTable(NSTableView table)
{
var columns = table.TableColumns();
columns[0].SetIdentifier(PreviewTableDelegate.CellIdentifiers[0]);
columns[0].MinWidth = 50;
columns[0].MaxWidth = 200;
columns[0].Width = 60;
var bc = new NSButtonCell();
bc.SetButtonType(NSButtonType.OnOff);
// columns[0].DataCell = bc;
columns[0].Title = Configuration.Settings.Language.General.Apply;
columns[1].SetIdentifier(PreviewTableDelegate.CellIdentifiers[1]);
columns[1].MinWidth = 50;
columns[1].MaxWidth = 200;
columns[1].Width = 60;
columns[1].Title = Configuration.Settings.Language.General.LineNumber;
table.AddColumn(new NSTableColumn(PreviewTableDelegate.CellIdentifiers[2])
{
MinWidth = 100,
MaxWidth = 2000,
Width = 250,
Title = Configuration.Settings.Language.General.Before,
});
table.AddColumn(new NSTableColumn(PreviewTableDelegate.CellIdentifiers[3])
{
MinWidth = 100,
MaxWidth = 2000,
Width = 250,
Title = Configuration.Settings.Language.General.After,
});
}
示例3: ObjectValueForTableColumn
public NSObject ObjectValueForTableColumn (NSTableView table, NSTableColumn col, int row)
{
try {
if (Entries != null) {
X509Certificate2 cert = Entries [row].Cert;
switch (col.Identifier) {
case "Alias":
return (NSString)Entries [row].Alias;
case VMIdentityConstants.CERT_ISSUED_BY:
return (NSString)cert.Issuer;
case VMIdentityConstants.CERT_ISSUED_DATE:
return (NSString)cert.NotBefore.ToShortDateString ();
case VMIdentityConstants.CERT_EXPIRATION_DATE:
return (NSString)cert.NotAfter.ToShortDateString ();
case VMIdentityConstants.CERT_INTENDED_PURPOSES:
return (NSString)cert.GetKeyUsage ();
case VMIdentityConstants.CERT_STATUS:
break;
case VMIdentityConstants.CERT_ISSUED_TO:
return (NSString)cert.Subject;
}
}
} catch (Exception e) {
System.Diagnostics.Debug.WriteLine ("Error in fetching data : " + e.Message);
}
return null;
}
示例4: GetObjectValue
public NSObject GetObjectValue(NSTableView tableView, NSTableColumn tableColumn, nint row)
{
if (IsViewReady) {
Employee emp = DataStore.Employees[(int)row];
switch (tableColumn.Identifier)
{
case "FirstName":
return new NSString(emp.FirstName);
case "LastName":
return new NSString(emp.LastName);
case "DepartmentName":
NSPopUpButtonCell button = tableColumn.DataCellForRow(row) as NSPopUpButtonCell;
button.RemoveAllItems();
foreach(Department dep in DataStore.Departments) {
button.Menu.AddItem(dep.Name, new ObjCRuntime.Selector("departmentSelected:"), "");
}
return button;
default:
return new NSString("");
}
}
else return new NSString("");
}
示例5: GetViewForItem
public override NSView GetViewForItem(NSTableView tableView, NSTableColumn tableColumn, nint row)
{
int r = (int)row;
if (tableColumn.Identifier == CellIdentifierEnabled)
{
NSButton v = null;
if (v == null)
{
v = new NSButton();
v.Title = string.Empty;
v.SetButtonType(NSButtonType.Switch);
if (_dataSource.Items[r].Checked)
{
v.State = NSCellStateValue.On;
}
else
{
v.State = NSCellStateValue.Off;
}
v.Activated += (object sender, EventArgs e) =>
{
var b = v.State == NSCellStateValue.On;
_dataSource.Items[r].Checked = b;
_controller.SaveRuleState(r, b);
};
}
return v;
}
// This pattern allows you reuse existing views when they are no-longer in use.
// If the returned view is null, you instance up a new view
// If a non-null view is returned, you modify it enough to reflect the new data
NSTextField view = (NSTextField)tableView.MakeView(CellIdentifier, this);
if (view == null)
{
view = new NSTextField();
view.Identifier = CellIdentifier;
view.BackgroundColor = NSColor.Clear;
view.Bordered = false;
view.Selectable = false;
view.Editable = false;
}
// Setup view based on the column selected
switch (tableColumn.Identifier)
{
case CellIdentifierEnabled:
view.StringValue = _dataSource.Items[r].Checked.ToString();
break;
case CellIdentifierFixWhat:
view.StringValue = _dataSource.Items[r].Name;
break;
case CellIdentifierExample:
view.StringValue = _dataSource.Items[r].Example;
break;
}
return view;
}
示例6: NumberOfRowsInTableView
public int NumberOfRowsInTableView (NSTableView table)
{
var groups = (Groups != null) ? Groups.Count : 0;
var users = (Users != null) ? Users.Count : 0;
var solutionUsers = (SolutionUsers != null) ? SolutionUsers.Count : 0;
return groups + users + solutionUsers;
}
示例7: ObjectValueForTableColumn
public NSObject ObjectValueForTableColumn (NSTableView table, NSTableColumn col, int row)
{
var value = (NSString)string.Empty;
ActionHelper.Execute (delegate() {
if (Entries != null) {
var obj = (this.Entries [row]) as UserDto;
switch (col.Identifier) {
case "Name":
value = (NSString)obj.Name;
break;
case "FirstName":
value = (NSString)obj.PersonDetails.FirstName;
break;
case "LastName":
value = (NSString)obj.PersonDetails.LastName;
break;
case "Email":
value = (NSString)obj.PersonDetails.EmailAddress;
break;
case "Description":
value = (NSString)obj.PersonDetails.Description;
break;
default:
break;
}
}
});
return value;
}
示例8: ObjectValueForTableColumn
public NSObject ObjectValueForTableColumn (NSTableView table, NSTableColumn col, int row)
{
var value = (NSString)string.Empty;
ActionHelper.Execute (delegate() {
if (Entries != null) {
var obj = (this.Entries [row]) as AssertionConsumerServiceDto;
switch (col.Identifier) {
case "Name":
value = (NSString)obj.Name;
break;
case "Index":
value = (NSString)obj.Index.ToString ();
break;
case "Binding":
value = (NSString)obj.Binding;
break;
case "Endpoint":
value = (NSString)obj.Endpoint;
break;
case "IsDefault":
value = (NSString)obj.IsDefault.ToString ();
break;
default:
break;
}
}
});
return value;
}
示例9: NumberOfRowsInTableView
public int NumberOfRowsInTableView (NSTableView table)
{
if (data != null)
return data.Count;
else
return 0;
}
示例10: GetViewForItem
public override NSView GetViewForItem (NSTableView tableView, NSTableColumn tableColumn, nint row)
{
int r = (int)row;
if (tableColumn.Identifier == CellIdentifierApply)
{
//var v = (NSButton)tableView.MakeView (CellIdentifier, this);
NSButton v = null;
if (v == null)
{
v = new NSButton();
v.Title = string.Empty;
v.SetButtonType(NSButtonType.Switch);
if (_dataSource.Items[r].Apply)
{
v.State = NSCellStateValue.On;
}
else
{
v.State = NSCellStateValue.Off;
}
v.Activated += (object sender, EventArgs e) =>
{
_dataSource.Items[r].Apply = v.State == NSCellStateValue.On;
};
}
return v;
}
// This pattern allows you reuse existing views when they are no-longer in use.
// If the returned view is null, you instance up a new view
// If a non-null view is returned, you modify it enough to reflect the new data
NSTextField view = (NSTextField)tableView.MakeView (CellIdentifier, this);
if (view == null) {
view = new NSTextField ();
view.Identifier = CellIdentifier;
view.BackgroundColor = NSColor.Clear;
view.Bordered = false;
view.Selectable = false;
view.Editable = false;
}
// Setup view based on the column selected
switch (tableColumn.Identifier) {
case CellIdentifierApply:
view.StringValue = _dataSource.Items[r].Apply.ToString();
break;
case CellIdentifierLineNumber:
view.StringValue = _dataSource.Items[r].LineNumber;
break;
case CellIdentifierBefore:
view.StringValue = _dataSource.Items[r].Before.ToListViewString();
break;
case CellIdentifierAfter:
view.StringValue = _dataSource.Items[r].After.ToListViewString();
break;
}
return view;
}
示例11: NumberOfRowsInTableView
public int NumberOfRowsInTableView (NSTableView table)
{
if (Entries != null)
return this.Entries.Count;
else
return 0;
}
示例12: GetViewForItem
public override NSView GetViewForItem (NSTableView tableView, NSTableColumn tableColumn, nint row)
{
int r = (int)row;
// This pattern allows you reuse existing views when they are no-longer in use.
// If the returned view is null, you instance up a new view
// If a non-null view is returned, you modify it enough to reflect the new data
NSTextField view = (NSTextField)tableView.MakeView (CellIdentifier, this);
if (view == null) {
view = new NSTextField ();
view.Identifier = CellIdentifier;
view.BackgroundColor = NSColor.Clear;
view.Bordered = false;
view.Selectable = false;
view.Editable = false;
}
// Setup view based on the column selected
switch (tableColumn.Identifier) {
case CellIdentifierFirst:
view.StringValue = DataSource.Items[r];
break;
}
return view;
}
示例13: ValidateDrop
public override NSDragOperation ValidateDrop(NSTableView tableView, NSDraggingInfo info, nint row, NSTableViewDropOperation dropOperation)
{
if (_openSubtitleAction != null)
{
return NSDragOperation.Copy;
}
return NSDragOperation.None;
}
示例14: InitializeTable
private void InitializeTable(NSTableView table)
{
var columns = table.TableColumns();
columns[0].SetIdentifier(StringListTableDelegate.CellIdentifiers[0]);
columns[0].MinWidth = 50;
columns[0].MaxWidth = 20000;
columns[0].Width = 2060;
}
示例15: CocoaResultViewHelper
public CocoaResultViewHelper(NSTableView resultView)
{
_resultView = resultView;
_resultView.SetDelegate(d => {
d.TableViewSelectionDidChange += HandleResultViewTableViewSelectionDidChange;
});
_results = new CocoaResultsDataSource();
_resultView.DataSource = _results;
}