当前位置: 首页>>代码示例>>C#>>正文


C# NSTableView.MakeView方法代码示例

本文整理汇总了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;
        }  
开发者ID:SubtitleEdit,项目名称:subtitleedit-mac,代码行数:60,代码来源:PreviewTableDelegate.cs

示例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;
        }  
开发者ID:SubtitleEdit,项目名称:subtitleedit-mac,代码行数:26,代码来源:StringListTableDelegate.cs

示例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;
        }
开发者ID:SubtitleEdit,项目名称:subtitleedit-mac,代码行数:60,代码来源:FixCommonErrorsTableDelegate.cs

示例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;
		}
开发者ID:hitchingsh,项目名称:mac-samples,代码行数:54,代码来源:ProductTableDelegate.cs

示例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;
		}
开发者ID:hitchingsh,项目名称:mac-samples,代码行数:15,代码来源:QuakeTableSourse.cs

示例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;
 }
开发者ID:talisqualis,项目名称:MvvmCross-Build,代码行数:16,代码来源:MvxTableViewSource.cs

示例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;
		}
开发者ID:pbbpage,项目名称:mac-samples,代码行数:43,代码来源:ProductTableDelegate.cs

示例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;
        }
开发者ID:ailen0ada,项目名称:RxUISimpleTimer,代码行数:20,代码来源:LapTimesDataSource.cs

示例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;		
		}
开发者ID:xamarin,项目名称:mac-samples,代码行数:22,代码来源:NSTableViewExample.cs

示例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;
		}
开发者ID:runecats,项目名称:mac-samples,代码行数:21,代码来源:TableDelegate.cs

示例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
//.........这里部分代码省略.........
开发者ID:SubtitleEdit,项目名称:subtitleedit-mac,代码行数:101,代码来源:SubtitleTableDelegate.cs

示例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;
        }
开发者ID:perfp,项目名称:Chip8,代码行数:13,代码来源:MainWindowController.cs

示例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;
		}
开发者ID:RangoLee,项目名称:mac-samples,代码行数:86,代码来源:ProductTableDelegate.cs

示例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;
        }
开发者ID:SubtitleEdit,项目名称:subtitleedit-mac,代码行数:73,代码来源:MultipleRulesTableDelegate.cs


注:本文中的NSTableView.MakeView方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。