本文整理汇总了C#中NSTableView.MakeView方法的典型用法代码示例。如果您正苦于以下问题:C# NSTableView.MakeView方法的具体用法?C# NSTableView.MakeView怎么用?C# NSTableView.MakeView使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NSTableView
的用法示例。
在下文中一共展示了NSTableView.MakeView方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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;
}
示例2: 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;
}
示例3: 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;
}
示例4: GetViewForItem
public override NSView GetViewForItem (NSTableView tableView, NSTableColumn tableColumn, nint 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
NSTableCellView view = (NSTableCellView)tableView.MakeView (tableColumn.Title, this);
if (view == null) {
view = new NSTableCellView ();
if (tableColumn.Title == "Product") {
view.ImageView = new NSImageView (new CGRect (0, 0, 16, 16));
view.AddSubview (view.ImageView);
view.TextField = new NSTextField (new CGRect (20, 0, 400, 16));
} else {
view.TextField = new NSTextField (new CGRect (0, 0, 400, 16));
}
view.TextField.AutoresizingMask = NSViewResizingMask.WidthSizable;
view.AddSubview (view.TextField);
view.Identifier = tableColumn.Title;
view.TextField.BackgroundColor = NSColor.Clear;
view.TextField.Bordered = false;
view.TextField.Selectable = false;
view.TextField.Editable = true;
view.TextField.EditingEnded += (sender, e) => {
// Take action based on type
switch(view.Identifier) {
case "Product":
DataSource.Products [(int)view.TextField.Tag].Title = view.TextField.StringValue;
break;
case "Details":
DataSource.Products [(int)view.TextField.Tag].Description = view.TextField.StringValue;
break;
}
};
}
// Tag view
view.TextField.Tag = row;
// Setup view based on the column selected
switch (tableColumn.Title) {
case "Product":
view.ImageView.Image = NSImage.ImageNamed ("tag.png");
view.TextField.StringValue = DataSource.Products [(int)row].Title;
break;
case "Details":
view.TextField.StringValue = DataSource.Products [(int)row].Description;
break;
}
return view;
}
示例5: GetViewForItem
public override NSView GetViewForItem (NSTableView tableView, NSTableColumn tableColumn, int row)
{
string identifier = tableColumn.Identifier;
NSTableCellView cellView = (NSTableCellView)tableView.MakeView (identifier, this);
Quake quake = quakesSource [row];
if (identifier == ColumnIdentifierPlace)
cellView.TextField.StringValue = quake.Location;
else if (identifier == ColumnIdentifierTime)
cellView.TextField.ObjectValue = quake.Date;
else if (identifier == ColumnIdentifierMagnitude)
cellView.TextField.ObjectValue = quake.Magnitude;
return cellView;
}
示例6: GetOrCreateViewFor
private NSView GetOrCreateViewFor(NSTableView tableView, NSTableColumn tableColumn)
{
var view = tableView.MakeView(tableColumn.Identifier, this);
var bindableColumn = tableColumn as MvxTableColumn;
if (bindableColumn != null)
{
if (view == null)
view = new MvxTableCellView(bindableColumn.BindingText);
else
{
IMvxBindingContextOwner bindableView = view as IMvxBindingContextOwner;
bindableView.CreateBindingContext(bindableColumn.BindingText);
}
}
return view;
}
示例7: GetViewForItem
public override NSView GetViewForItem (NSTableView tableView, NSTableColumn tableColumn, nint 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 (tableColumn.Title, this);
if (view == null) {
view = new NSTextField ();
view.Identifier = tableColumn.Title;
view.BackgroundColor = NSColor.Clear;
view.Bordered = false;
view.Selectable = false;
view.Editable = true;
view.EditingEnded += (sender, e) => {
// Take action based on type
switch(view.Identifier) {
case "Product":
DataSource.Products [(int)view.Tag].Title = view.StringValue;
break;
case "Details":
DataSource.Products [(int)view.Tag].Description = view.StringValue;
break;
}
};
}
// Tag view
view.Tag = row;
// Setup view based on the column selected
switch (tableColumn.Title) {
case "Product":
view.StringValue = DataSource.Products [(int)row].Title;
break;
case "Details":
view.StringValue = DataSource.Products [(int)row].Description;
break;
}
return view;
}
示例8: GetViewForItem
public override NSView GetViewForItem(NSTableView tableView, NSTableColumn tableColumn, nint row)
{
var view = (NSTableCellView)tableView.MakeView(tableColumn.Identifier, this);
var entry = DataSource.Items[(int)row];
switch (tableColumn.Identifier)
{
case ColumnIdentifierLap:
view.TextField.StringValue = (row + 1).ToString();
break;
case ColumnIdentifierElapsed:
view.TextField.StringValue = converter(entry.Elapsed);
break;
case ColumnIdentifierDuration:
view.TextField.StringValue = converter(entry.Duration);
break;
}
return view;
}
示例9: GetViewForItem
// Returns the NSView for a given column/row. NSTableView is strange as unlike NSOutlineView
// it does not pass in the data for the given item (obtained from the DataSource) for the NSView APIs
public override NSView GetViewForItem (NSTableView tableView, NSTableColumn tableColumn, nint 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 (identifer, this);
if (view == null) {
view = new NSTextField ();
view.Identifier = identifer;
view.Bordered = false;
view.Selectable = false;
view.Editable = false;
}
if (tableColumn.Identifier == "Values")
view.StringValue = (NSString)row.ToString ();
else
view.StringValue = (NSString)NumberWords [row];
return view;
}
示例10: GetViewForItem
public override NSView GetViewForItem (NSTableView tableView, NSTableColumn tableColumn, nint 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;
}
// Grab the data for the given table column
view.StringValue = tableView.DataSource.GetObjectValue (tableView, tableColumn, row) + "";
// Return the data
return view;
}
示例11: 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
var p = DataSource.Subtitle.Paragraphs[r];
view.BackgroundColor = NSColor.Clear;
switch (tableColumn.Identifier)
{
case CellIdentifierNumber:
view.StringValue = p.Number.ToString(CultureInfo.InvariantCulture);
break;
case CellIdentifierStartTime:
view.StringValue = p.StartTime.ToString();
if (Configuration.Settings.Tools.ListViewSyntaxColorOverlap && r > 0 && r < DataSource.Subtitle.Paragraphs.Count)
{
Paragraph prev = DataSource.Subtitle.Paragraphs[r - 1];
if (p.StartTime.TotalMilliseconds < prev.EndTime.TotalMilliseconds)
{
ColorView(view);
return view;
}
}
break;
case CellIdentifierEndTime:
view.StringValue = p.EndTime.ToString();
if (Configuration.Settings.Tools.ListViewSyntaxColorOverlap && r >= 0 && r < DataSource.Subtitle.Paragraphs.Count - 1)
{
Paragraph next = DataSource.Subtitle.Paragraphs[r + 1];
if (p.EndTime.TotalMilliseconds > next.StartTime.TotalMilliseconds)
{
ColorView(view);
return view;
}
}
break;
case CellIdentifierDuration:
view.StringValue = p.Duration.ToShortString();
if (Configuration.Settings.Tools.ListViewSyntaxColorDurationBig)
{
if (p.Duration.TotalMilliseconds > Configuration.Settings.General.SubtitleMaximumDisplayMilliseconds)
{
ColorView(view);
return view;
}
}
if (Configuration.Settings.Tools.ListViewSyntaxColorDurationBig)
{
if (p.Duration.TotalMilliseconds < Configuration.Settings.General.SubtitleMinimumDisplayMilliseconds)
{
ColorView(view);
return view;
}
double charactersPerSecond = Utilities.GetCharactersPerSecond(p);
if (charactersPerSecond > Configuration.Settings.General.SubtitleMaximumCharactersPerSeconds)
{
ColorView(view);
return view;
}
}
break;
case CellIdentifierText:
view.StringValue = p.Text.ToListViewString();
if (Configuration.Settings.Tools.ListViewSyntaxColorLongLines)
{
string s = HtmlUtil.RemoveHtmlTags(p.Text, true);
var lines = s.SplitToLines();
// number of lines
int noOfLines = lines.Length;
if (noOfLines > Configuration.Settings.Tools.ListViewSyntaxMoreThanXLinesX)
{
ColorView(view);
return view;
}
// single line max length
foreach (string line in s.SplitToLines())
{
if (line.Length > Configuration.Settings.General.SubtitleLineMaximumLength)
{
ColorView(view);
return view;
}
}
// total length
//.........这里部分代码省略.........
示例12: GetViewForItem
public override NSView GetViewForItem(NSTableView tableView, NSTableColumn tableColumn, int row)
{
if(tableView.TableColumns()[0] != tableColumn)
return null;
NSTextField textField = (NSTextField)tableView.MakeView("myView", tableView);
if (textField == null){
textField = new NSTextField(tableView.VisibleRect());
textField.Identifier = "myView";
}
textField.StringValue = names[row];
return textField;
}
示例13: GetViewForItem
public override NSView GetViewForItem (NSTableView tableView, NSTableColumn tableColumn, nint 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
NSTableCellView view = (NSTableCellView)tableView.MakeView (tableColumn.Title, this);
if (view == null) {
view = new NSTableCellView ();
// Configure the view
view.Identifier = tableColumn.Title;
// Take action based on title
switch (tableColumn.Title) {
case "Product":
view.ImageView = new NSImageView (new CGRect (0, 0, 16, 16));
view.AddSubview (view.ImageView);
view.TextField = new NSTextField (new CGRect (20, 0, 400, 16));
ConfigureTextField (view, row);
break;
case "Details":
view.TextField = new NSTextField (new CGRect (0, 0, 400, 16));
ConfigureTextField (view, row);
break;
case "Action":
// Create new button
var button = new NSButton (new CGRect (0, 0, 81, 16));
button.SetButtonType (NSButtonType.MomentaryPushIn);
button.Title = "Delete";
button.Tag = row;
// Wireup events
button.Activated += (sender, e) => {
// Get button and product
var btn = sender as NSButton;
var product = DataSource.Products [(int)btn.Tag];
// Configure alert
var alert = new NSAlert () {
AlertStyle = NSAlertStyle.Informational,
InformativeText = $"Are you sure you want to delete {product.Title}? This operation cannot be undone.",
MessageText = $"Delete {product.Title}?",
};
alert.AddButton ("Cancel");
alert.AddButton ("Delete");
alert.BeginSheetForResponse (Controller.View.Window, (result) => {
// Should we delete the requested row?
if (result == 1001) {
// Remove the given row from the dataset
DataSource.Products.RemoveAt((int)btn.Tag);
Controller.ReloadTable ();
}
});
};
// Add to view
view.AddSubview (button);
break;
}
}
// Setup view based on the column selected
switch (tableColumn.Title) {
case "Product":
view.ImageView.Image = NSImage.ImageNamed ("tag.png");
view.TextField.StringValue = DataSource.Products [(int)row].Title;
view.TextField.Tag = row;
break;
case "Details":
view.TextField.StringValue = DataSource.Products [(int)row].Description;
view.TextField.Tag = row;
break;
case "Action":
foreach (NSView subview in view.Subviews) {
var btn = subview as NSButton;
if (btn != null) {
btn.Tag = row;
}
}
break;
}
return view;
}
示例14: 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) =>
{
_dataSource.Items[r].Checked = v.State == NSCellStateValue.On;
_controller.GeneratePreview();
};
}
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 CellIdentifierFindWhat:
view.StringValue = _dataSource.Items[r].FindWhat;
break;
case CellIdentifierReplaceWith:
view.StringValue = _dataSource.Items[r].ReplaceWith;
break;
case CellIdentifierSearchType:
switch (_dataSource.Items[r].SearchType)
{
case 0:
view.StringValue = Configuration.Settings.Language.MultipleReplace.Normal;
break;
case 1:
view.StringValue = Configuration.Settings.Language.MultipleReplace.CaseSensitive;
break;
default:
view.StringValue = Configuration.Settings.Language.MultipleReplace.RegularExpression;
break;
}
break;
}
return view;
}