public override NSView GetView(NSOutlineView outlineView, NSTableColumn tableColumn, NSObject item) { NSTableCellView view = (NSTableCellView)outlineView.MakeView("cell", this); if (view == null) { view = new NSTableCellView() { Identifier = "cell", ImageView = new NSImageView(new CGRect(2, 0, 16, 16)), TextField = new NSTextField(new CGRect(20, 0, 900, 16)) { AutoresizingMask = NSViewResizingMask.WidthSizable, BackgroundColor = NSColor.Clear, Bordered = false, Selectable = false, Editable = false } }; view.AddSubview(view.ImageView); view.AddSubview(view.TextField); } var node = item as TreeNode; view.ImageView.Image = NSImage.ImageNamed(node.IsGroup ? "iconGroup" : "iconSong"); view.TextField.StringValue = node.Name; view.TextField.TextColor = node.IsGroup ? NSColor.Blue : NSColor.ControlText; return(view); }
public override NSView GetView (NSOutlineView outlineView, NSTableColumn tableColumn, NSObject item) { // Cast item var product = item as Product; // 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)outlineView.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 = !product.IsProductGroup; } // Tag view view.TextField.Tag = outlineView.RowForItem (item); // Allow for edit view.TextField.EditingEnded += (sender, e) => { // Grab product var prod = outlineView.ItemAtRow(view.Tag) as Product; // Take action based on type switch(view.Identifier) { case "Product": prod.Title = view.TextField.StringValue; break; case "Details": prod.Description = view.TextField.StringValue; break; } }; // Setup view based on the column selected switch (tableColumn.Title) { case "Product": view.ImageView.Image = NSImage.ImageNamed (product.IsProductGroup ? "tags.png" : "tag.png"); view.TextField.StringValue = product.Title; break; case "Details": view.TextField.StringValue = product.Description; break; } return view; }
public override NSView GetViewForItem(NSTableView tableView, NSTableColumn tableColumn, nint row) { NSTableCellView view = (NSTableCellView)tableView.MakeView(CellIdentifier, this); if (view == null) { view = new NSTableCellView(); var click = new NSButton(new CGRect(0, -10, 400, 42)); click.SetButtonType(NSButtonType.MomentaryPushIn); click.BezelStyle = NSBezelStyle.RegularSquare; click.AlphaValue = 0; click.Title = ""; click.Tag = row; click.Activated += (sender, e) => { if (DataSource.addresses[(int)row].extended && (int)row != 0) { DataSource.addresses[(int)row].top = true; wvc.update(); var btw = sender as NSButton; } ; }; view.TextField = new NSTextField(new CGRect(0, 0, 400, 35)); view.Identifier = CellIdentifier; view.TextField.Font = NSFont.BoldSystemFontOfSize(28); view.TextField.BackgroundColor = NSColor.Clear; view.TextField.Bordered = false; view.TextField.Selectable = false; view.TextField.Editable = false; view.AddSubview(view.TextField); view.AddSubview(click); } // Setup view based on the column selected switch (tableColumn.Title) { case "address": view.TextField.StringValue = DataSource.addresses[(int)row].Address; foreach (NSView subview in view.Subviews) { var btw = subview as NSButton; if (btw != null) { btw.Tag = row; } } break; } return(view); }
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; }
private void ConfigureTextField(NSTableCellView view, nint row) { // Add to view view.TextField.AutoresizingMask = NSViewResizingMask.WidthSizable; view.AddSubview(view.TextField); // Configure view.TextField.BackgroundColor = NSColor.Clear; view.TextField.Bordered = false; view.TextField.Selectable = false; view.TextField.Editable = true; // Wireup events view.TextField.EditingEnded += (sender, e) => { // Take action based on type switch (view.Identifier) { case "Name": _dataSource.Items[(int)view.TextField.Tag].Name = view.TextField.StringValue; break; case "Important": _dataSource.Items[(int)view.TextField.Tag].IsImportant = view.TextField.StringValue.ToUpper() == "TRUE"; break; } }; // Tag view view.TextField.Tag = row; }
private void ConfigureTextField(NSTableCellView view, nint row) { // Add to view view.TextField.AutoresizingMask = NSViewResizingMask.WidthSizable; view.AddSubview(view.TextField); // Configure view.TextField.BackgroundColor = NSColor.Clear; view.TextField.Bordered = false; view.TextField.Selectable = false; view.TextField.Editable = true; // Wireup events 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; }
private void ConfigureTextField (NSTableCellView view, nint row) { // Add to view view.TextField.AutoresizingMask = NSViewResizingMask.WidthSizable; view.AddSubview (view.TextField); // Configure view.TextField.BackgroundColor = NSColor.Clear; view.TextField.Bordered = false; view.TextField.Selectable = false; view.TextField.Editable = true; // Wireup events 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; }
public override NSView GetView(NSOutlineView outlineView, NSTableColumn tableColumn, NSObject item) { var node = (Node)item; var view = new NSTableCellView(); //TextField view.TextField = new NSTextField(new CGRect(20, 0, 400, 16)); view.AddSubview(view.TextField); view.TextField.BackgroundColor = NSColor.Clear; view.TextField.Bordered = false; view.TextField.Editable = false; view.TextField.Selectable = false; view.TextField.StringValue = node.Name; view.TextField.ToolTip = node.Name; //CheckBox var checkBox = new NSButton(new CGRect(5, 0, 16, 16)); view.AddSubview(checkBox); checkBox.SetButtonType(NSButtonType.Switch); checkBox.AllowsMixedState = true; checkBox.State = StateConverter.ConvertNodeState(node); checkBox.Activated += (sender, e) => { var ckb = (NSButton)sender; if (ckb.State == NSCellStateValue.Mixed) { ckb.State = NSCellStateValue.On; } var state = StateConverter.ConvertCheckboxState(ckb); node.SetStateToChildren(state); node.SetStateToParent(state); outlineView.ReloadData(); }; return(view); }
internal NSTableCellView GetFTAnalyzerGridCell(NSTableView tableView, NSTableColumn tableColumn, nint row) { var index = Array.IndexOf(_fieldNames, tableColumn.Identifier); if (index < 0 || index > _properties.Length) { return(null); } var property = _properties[index]; NSTextAlignment alignment = NSTextAlignment.Left; var width = tableColumn.Width; ColumnDetail[] x = property.GetCustomAttributes(typeof(ColumnDetail), false) as ColumnDetail[]; if (x?.Length == 1) { alignment = x[0].Alignment; width = x[0].ColumnWidth; } if (!(tableView.MakeView(CellIdentifier, this) is NSTableCellView cellView)) { var textField = new NSTextField { BackgroundColor = NSColor.Clear, LineBreakMode = NSLineBreakMode.TruncatingTail, Bordered = false, Selectable = false, Editable = false, Alignment = alignment, AutoresizingMask = NSViewResizingMask.MinYMargin | NSViewResizingMask.WidthSizable, AutoresizesSubviews = true, TranslatesAutoresizingMaskIntoConstraints = false, AllowsDefaultTighteningForTruncation = true, }; if (tableView.AutosaveName == "PrintView") { textField.Font = NSFont.SystemFontOfSize(8); } cellView = new NSTableCellView { Identifier = CellIdentifier, TextField = textField, AutoresizesSubviews = true, AutoresizingMask = NSViewResizingMask.HeightSizable | NSViewResizingMask.WidthSizable }; cellView.AddSubview(textField); var views = new NSMutableDictionary { { new NSString("textField"), textField } }; cellView.AddConstraints(NSLayoutConstraint.FromVisualFormat($"H:|[textField({width}@750)]|", NSLayoutFormatOptions.AlignAllTop, null, views)); cellView.AddConstraints(NSLayoutConstraint.FromVisualFormat("V:|[textField]|", NSLayoutFormatOptions.AlignAllTop, null, views)); NSLayoutConstraint.ActivateConstraints(cellView.Constraints); } return(cellView); }
private void ConfigureTextField(NSTableCellView view, nint row) { // Add to view view.TextField.AutoresizingMask = NSViewResizingMask.WidthSizable; view.AddSubview(view.TextField); // Configure view.TextField.BackgroundColor = NSColor.Clear; view.TextField.Bordered = false; view.TextField.Selectable = false; view.TextField.Editable = true; // Tag view view.TextField.Tag = row; }
private void ConfigureTextField(NSTableCellView view, nint row) { // Add to view view.TextField.AutoresizingMask = NSViewResizingMask.WidthSizable; view.AddSubview(view.TextField); // Configure view.TextField.BackgroundColor = NSColor.Clear; view.TextField.Bordered = false; view.TextField.Selectable = false; if (string.Equals(view.Identifier, "Value")) { view.TextField.Editable = true; } else { view.TextField.Editable = false; } // Wireup events view.TextField.EditingEnded += (sender, e) => { // Take action based on type switch (view.Identifier) { case "Value": string currKey = _ds.displayAttrDTOList[(int)view.TextField.Tag].Name; if (currKey != "objectClass") { if (!string.Equals(_ds.displayAttrDTOList[(int)view.TextField.Tag].Value, view.TextField.StringValue)) { _ds.displayAttrDTOList[(int)view.TextField.Tag].Value = view.TextField.StringValue; _ds.displayAttrDTOList[(int)view.TextField.Tag].Dirty = true; _ds.modData.Add(currKey); _propViewCtl.SetEditVisibility(true); } if (_ds.displayAttrDTOList[(int)view.TextField.Tag].Dirty) { view.TextField.BackgroundColor = NSColor.Orange; } } break; } }; // Tag view view.TextField.Tag = row; }
public override NSView GetView(NSOutlineView outlineView, NSTableColumn tableColumn, NSObject item) { // Cast item var product = item as Product; // 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)outlineView.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 = !product.IsProductGroup; } // Tag view view.TextField.Tag = outlineView.RowForItem(item); // Allow for edit view.TextField.EditingEnded += (sender, e) => { // Grab product var prod = outlineView.ItemAtRow(view.Tag) as Product; // Take action based on type switch (view.Identifier) { case "Product": prod.Title = view.TextField.StringValue; break; case "Details": prod.Description = view.TextField.StringValue; break; } }; // Setup view based on the column selected switch (tableColumn.Title) { case "Product": view.ImageView.Image = NSImage.ImageNamed(product.IsProductGroup ? "tags.png" : "tag.png"); view.TextField.StringValue = product.Title; break; case "Details": view.TextField.StringValue = product.Description; break; } return(view); }
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); view = new NSTableCellView(); var showPassword = DataSource.Records[(int)row].ShowPassword; // Configure the view view.Identifier = tableColumn.Title; // Take action based on title switch (tableColumn.Title) { case "Website/Service": case "Account Name": view.TextField = new NSTextField(new CGRect(0, 0, 400, 16)); ConfigureTextField(view, row); break; case "Password": view.TextField = showPassword ? new NSTextField(new CGRect(0, 0, 400, 16)) : new NSSecureTextField(new CGRect(0, 0, 400, 16)); ConfigureTextField(view, row); break; case "Actions": // Create new button var removeButton = new NSButton(new CGRect(0, 0, 60, 16)); removeButton.Tag = row; removeButton.Bordered = false; removeButton.Cell = new NSButtonCell { BackgroundColor = NSColor.DarkGray, Title = "Remove" }; // Wireup events removeButton.Activated += (sender, e) => { // Get button and product var btn = sender as NSButton; var record = DataSource.Records[(int)btn.Tag]; var connection = SqliteManager.GetDatabaseConnection(); // Configure alert var alert = new NSAlert() { AlertStyle = NSAlertStyle.Informational, InformativeText = $"Are you sure you want to delete data for {record.Website}? This operation cannot be undone.", MessageText = $"Delete data for {record.Website}?", }; 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.RemoveRecord(record, connection); Controller.PushView(); } }); }; view.AddSubview(removeButton); var showButton = new NSButton(new CGRect(70, 0, 60, 16)); showButton.Tag = row; showButton.Cell = new NSButtonCell { BackgroundColor = NSColor.DarkGray, Title = showPassword ? "Hide" : "Show" }; showButton.Activated += (sender, e) => { var btn = sender as NSButton; var selectedRecord = DataSource.Records[(int)btn.Tag]; foreach (var record in DataSource.Records) { record.ShowPassword = false; } selectedRecord.ShowPassword = showPassword ? false : true; Controller.PushView(); }; view.AddSubview(showButton); var copyButton = new NSButton(new CGRect(140, 0, 60, 16)); copyButton.Tag = row; copyButton.Cell = new NSButtonCell { BackgroundColor = NSColor.DarkGray, Title = "Copy" }; copyButton.Activated += (sender, e) => { var btn = sender as NSButton; var selectedRecord = DataSource.Records[(int)btn.Tag]; var pasteboard = NSPasteboard.GeneralPasteboard; pasteboard.ClearContents(); pasteboard.WriteObjects(new NSString[] { (NSString)selectedRecord.Password }); }; view.AddSubview(copyButton); var editButton = new NSButton(new CGRect(210, 0, 60, 16)); editButton.Tag = row; editButton.Cell = new NSButtonCell { BackgroundColor = NSColor.DarkGray, Title = "Edit" }; editButton.Activated += (sender, e) => { var btn = sender as NSButton; var selectedRecord = DataSource.Records[(int)btn.Tag]; var connection = SqliteManager.GetDatabaseConnection(); Controller.RefillRecord(selectedRecord, btn.Tag); DataSource.RemoveRecord(selectedRecord, connection); }; view.AddSubview(editButton); break; } // Setup view based on the column selected switch (tableColumn.Title) { case "Website/Service": view.TextField.StringValue = DataSource.Records[(int)row].Website; break; case "Account Name": view.TextField.StringValue = DataSource.Records[(int)row].AccountName; break; case "Password": view.TextField.StringValue = DataSource.Records[(int)row].Password; break; case "Actions": foreach (NSView subview in view.Subviews) { var btn = subview as NSButton; if (btn != null) { btn.Tag = row; } } break; } return(view); }
private void ConfigureTextField(NSTableCellView view, nint row) { // Add to view view.TextField.AutoresizingMask = NSViewResizingMask.WidthSizable; view.AddSubview(view.TextField); // Configure view.TextField.BackgroundColor = NSColor.Clear; view.TextField.Bordered = false; view.TextField.Selectable = false; view.TextField.Editable = true; // Wireup events view.TextField.EditingEnded += (sender, e) => { Console.WriteLine(DataSource.MediaRecords[(int)view.TextField.Tag].ID, view.TextField.StringValue); DataSource.MediaRecords[(int)view.TextField.Tag].Connection = GetDatabaseConnection(); // Take action based on type switch (view.Identifier) { case "Media": if (view.TextField.StringValue.ToLower() == "book") { DataSource.MediaRecords[(int)view.TextField.Tag].Media = "Book"; } else if (view.TextField.StringValue.ToLower() == "film") { DataSource.MediaRecords[(int)view.TextField.Tag].Media = "Film"; } break; case "Title": DataSource.MediaRecords[(int)view.TextField.Tag].Title = view.TextField.StringValue; break; case "Creator": DataSource.MediaRecords[(int)view.TextField.Tag].Creator = view.TextField.StringValue; break; case "Language": DataSource.MediaRecords[(int)view.TextField.Tag].Language = view.TextField.StringValue; break; case "Rating": try { DataSource.MediaRecords[(int)view.TextField.Tag].Rating = Convert.ToInt32(view.TextField.StringValue); } catch { DataSource.MediaRecords[(int)view.TextField.Tag].Rating = 0; } break; case "Date": DataSource.MediaRecords[(int)view.TextField.Tag].Date = view.TextField.StringValue; break; case "Completion": if (view.TextField.StringValue.ToLower() == "completed") { DataSource.MediaRecords[(int)view.TextField.Tag].Status = "Completed"; } else if (view.TextField.StringValue.ToLower() == "in progress") { DataSource.MediaRecords[(int)view.TextField.Tag].Status = "In Progress"; } else if (view.TextField.StringValue.ToLower() == "wish list") { DataSource.MediaRecords[(int)view.TextField.Tag].Status = "Wish List"; } break; } Controller.ReloadMediaTable(); }; // Tag view view.TextField.Tag = row; }
public void Update(NSTableView tableView, Cell cell, NSTableCellView nativeCell) { ListView listView = cell.Parent as ListView; bool flag = listView != null && listView.CachingStrategy == ListViewCachingStrategy.RecycleElement; //TODO: Content Changed /* * if (this.cell != cell & flag) * { * if (cell != null) * cell.ContextActions.CollectionChanged -= OnContextItemsChanged; * cell.ContextActions.CollectionChanged += OnContextItemsChanged; * } */ CGRect frame = Frame; nfloat height = frame.Height; frame = tableView.Frame; nfloat width1 = frame.Width; nativeCell.Frame = new CGRect((nfloat)0, (nfloat)0, width1, height); nativeCell.NeedsLayout = true; var changedEventHandler = new PropertyChangedEventHandler(this.OnMenuItemPropertyChanged); this.tableView = tableView; //this.SetupSelection (tableView); if (this.cell != null) { if (!flag) { this.cell.PropertyChanged -= OnCellPropertyChanged; } if (this.menuItems.Count > 0) { // Not for Mac /* * if (!flag) * cell.ContextActions.CollectionChanged -= OnContextItemsChanged; */ foreach (BindableObject bindableObject in menuItems) { bindableObject.PropertyChanged -= changedEventHandler; } } this.menuItems.Clear(); } this.menuItems.AddRange(cell.ContextActions); this.cell = cell; if (!flag) { cell.PropertyChanged += OnCellPropertyChanged; // Not for Mac //cell.ContextActions.CollectionChanged += OnContextItemsChanged; } bool isOpen = false; if (this.scroller == null) { this.scroller = new NSScrollView(new CGRect((nfloat)0, (nfloat)0, width1, height)); //this.scroller.ScrollsToTop = false; scroller.HorizontalScroller.AlphaValue = 0; nativeCell.AddSubview(scroller); } else { this.scroller.Frame = new CGRect((nfloat)0, (nfloat)0, width1, height); //isOpen = this.ScrollDelegate.IsOpen; for (int index = 0; index < this.buttons.Count; ++index) { NSButton uiButton = this.buttons [index]; // ISSUE: reference to a compiler-generated method uiButton.RemoveFromSuperview(); uiButton.Dispose(); } this.buttons.Clear(); //this.ScrollDelegate.Unhook (this.scroller); //this.ScrollDelegate.Dispose (); } if (this.ContentCell != nativeCell) { if (this.ContentCell != null) { this.ContentCell.RemoveFromSuperview(); this.ContentCell = null; } this.ContentCell = nativeCell; CellTableViewCell cellTableViewCell = this.ContentCell as CellTableViewCell; if ((cellTableViewCell != null ? cellTableViewCell.Cell : (Cell)null) is ImageCell) { nfloat left = (nfloat)57; nfloat right = (nfloat)0; // not for Mac //this.SeparatorInset = new UIEdgeInsets ((nfloat)0, left, (nfloat)0, right); } this.scroller.AddSubview((NSView)nativeCell); } this.SetupButtons(width1, height); NSView uiView = (NSView)null; nfloat width2 = width1; for (int index = this.buttons.Count - 1; index >= 0; --index) { NSButton uiButton = this.buttons [index]; nfloat nfloat = width2; frame = uiButton.Frame; nfloat width3 = frame.Width; width2 = nfloat + width3; this.scroller.AddSubview((NSView)uiButton); } // TODO: Fix //this.scroller.Delegate = (IUIScrollViewDelegate)new ContextScrollViewDelegate (uiView, this.buttons, isOpen); //this.scroller.ContentSize = new CGSize (width2, height); if (isOpen) { //TODO: Open value this.scroller.HorizontalScroller.FloatValue = 0; // ScrollDelegate.ButtonsWidth; this.scroller.VerticalScroller.FloatValue = 0; } else { this.scroller.HorizontalScroller.FloatValue = 0; this.scroller.VerticalScroller.FloatValue = 0; } }
public override NSView GetViewForItem(NSTableView tableView, NSTableColumn tableColumn, nint row) { NSTableCellView view = (NSTableCellView)tableView.MakeView(tableColumn.Title, this); if (view == null) { view = new NSTableCellView(); if (tableColumn.Title == "Nome") { view.ImageView = new NSImageView(new CGRect(0, 0, 17, 17)); view.AddSubview(view.ImageView); view.TextField = new NSTextField(new CGRect(20, 0, 2, 17)); } else { view.TextField = new NSTextField(new CGRect(0, 0, 2, 17)); } 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 = false; view.TextField.EditingEnded += (sender, e) => { switch (view.Identifier) { case "Nome": DataSource.ViewArquivos [(int)view.TextField.Tag].Nome = view.TextField.StringValue; break; case "Tipo": DataSource.ViewArquivos [(int)view.TextField.Tag].Tipo = view.TextField.StringValue; break; case "Tamanho": DataSource.ViewArquivos [(int)view.TextField.Tag].Tamanho = view.TextField.StringValue; break; case "Compactado": DataSource.ViewArquivos [(int)view.TextField.Tag].Compactado = view.TextField.StringValue; break; case "Compressão": DataSource.ViewArquivos [(int)view.TextField.Tag].Compressao = view.TextField.StringValue; break; case "Data/Hora": DataSource.ViewArquivos [(int)view.TextField.Tag].DataHora = view.TextField.StringValue; break; case "Atributos": DataSource.ViewArquivos [(int)view.TextField.Tag].Atributos = view.TextField.StringValue; break; case "CRC 32": DataSource.ViewArquivos [(int)view.TextField.Tag].CRC32 = view.TextField.StringValue; break; case "OS": DataSource.ViewArquivos [(int)view.TextField.Tag].OS = view.TextField.StringValue; break; case "Compressor": DataSource.ViewArquivos [(int)view.TextField.Tag].Compressor = view.TextField.StringValue; break; } }; } // Tag view view.TextField.Tag = row; switch (tableColumn.Title) { case "Nome": clsViewArquivos cvarq = new clsViewArquivos(); string tagArquivo = cvarq.GetTagsArquivo((ViewArquivosDataSource)tableView.DataSource, (int)row); cvarq.SetStateArquivo(tableView.GetRowView(row, false), view, Convert.ToInt32(tagArquivo)); cvarq = null; view.TextField.Alignment = NSTextAlignment.Left; view.TextField.StringValue = DataSource.ViewArquivos [(int)row].Nome; break; case "Tipo": view.TextField.Alignment = NSTextAlignment.Center; view.TextField.StringValue = DataSource.ViewArquivos [(int)row].Tipo; break; case "Tamanho": view.TextField.Alignment = NSTextAlignment.Right; view.TextField.StringValue = DataSource.ViewArquivos [(int)row].Tamanho; break; case "Compactado": view.TextField.Alignment = NSTextAlignment.Right; view.TextField.StringValue = DataSource.ViewArquivos [(int)row].Compactado; break; case "Compressão": view.TextField.Alignment = NSTextAlignment.Center; view.TextField.StringValue = DataSource.ViewArquivos [(int)row].Compressao; break; case "Data/Hora": view.TextField.Alignment = NSTextAlignment.Center; view.TextField.StringValue = DataSource.ViewArquivos [(int)row].DataHora; break; case "Atributos": view.TextField.Alignment = NSTextAlignment.Center; view.TextField.StringValue = DataSource.ViewArquivos [(int)row].Atributos; break; case "CRC 32": view.TextField.Alignment = NSTextAlignment.Center; view.TextField.StringValue = DataSource.ViewArquivos [(int)row].CRC32; break; case "OS": view.TextField.Alignment = NSTextAlignment.Center; view.TextField.StringValue = DataSource.ViewArquivos [(int)row].OS; break; case "Compressor": view.TextField.Alignment = NSTextAlignment.Left; view.TextField.StringValue = DataSource.ViewArquivos [(int)row].Compressor; break; } return(view); }
public override NSView GetViewForItem(NSTableView tableView, NSTableColumn tableColumn, nint row) { NSTableCellView view = (NSTableCellView)tableView.MakeView(tableColumn.Title, this); if (view == null) { view = new NSTableCellView(); view.Identifier = tableColumn.Title; switch (tableColumn.Title) { case "Delete": 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 btw = sender as NSButton; var toDoItem = _dataSource.Items[(int)button.Tag]; // Configure alert var alert = new NSAlert() { AlertStyle = NSAlertStyle.Informational, InformativeText = $"Are you sure you want to delete {toDoItem.Name}? This operation cannot be undone.", MessageText = $"Delete {toDoItem.Name}?", }; alert.AddButton("Cancel"); alert.AddButton("Delete"); alert.BeginSheetForResponse(_viewController.View.Window, (result) => { // Should we delete the requested row? if (result == 1001) { // Remove the given row from the dataset _dataSource.Items.RemoveAt((int)button.Tag); _viewController.ReloadTable(); } }); }; // Add to view view.AddSubview(button); break; case "Name": view.TextField = new NSTextField(new CGRect(0, 0, 400, 16)); view.TextField.Identifier = c_cellIdentifier; ConfigureTextField(view, row); break; case "Important": var checkBoxView = new NSButton(new CGRect(0, 0, 81, 16)); checkBoxView.SetButtonType(NSButtonType.Switch); checkBoxView.Title = ""; checkBoxView.Alignment = NSTextAlignment.Center; checkBoxView.Identifier = c_cellIdentifier; view.AddSubview(checkBoxView); break; } } // Setup view based on the column selected switch (tableColumn.Title) { case "Name": view.TextField.StringValue = _dataSource.Items[(int)row].Name; break; case "Important": (view.Subviews[0] as NSButton).IntValue = _dataSource.Items[(int)row].IsImportant ? 1 : 0; break; } return(view); }
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("tags.png"); view.TextField.StringValue = DataSource.Products [(int)row].Title; break; case "Details": view.TextField.StringValue = DataSource.Products [(int)row].Description; break; } return(view); }
public NSView CreateView(ITableRow tableRow, string columnIdentifier) { var cellValue = tableRow.GetValue(columnIdentifier); var cell = tableRow.GetCell(columnIdentifier); if (!string.IsNullOrEmpty(cell.Text)) { cellValue.Text = cell.Text; } if (!string.IsNullOrEmpty(cell.Tooltip)) { cellValue.Tooltip = cell.Tooltip; } switch (cell.TypeCell) { case TypeCell.TextField: var tfCell = (ITextFieldCell)cell; var tf = new NSTextField(); tf.BackgroundColor = NSColor.Clear; tf.LineBreakMode = NSLineBreakMode.TruncatingTail; tf.Bordered = false; tf.Editable = tfCell.Editable; tf.Selectable = tfCell.Selectable; tf.StringValue = cellValue.Text; tf.ToolTip = cellValue.Tooltip; return(tf); case TypeCell.TextView: var txtvCell = (ITextViewCell)cell; var txtv = new NSTextView(); txtv.BackgroundColor = NSColor.Clear; txtv.Editable = txtvCell.Editable; txtv.Selectable = txtvCell.Selectable; txtv.Value = cellValue.Text; txtv.ToolTip = cellValue.Tooltip; return(txtv); case TypeCell.Button: var btnCell = (IButtonCell)cell; //var btn = NSButton.CreateButton(btnCell.Text, btnCell.Activated); var btnView = new NSButton(new CGRect(0, 0, 80, 16)); btnView.SetButtonType(NSButtonType.MomentaryPushIn); btnView.BezelStyle = NSBezelStyle.Rounded; btnView.Bordered = true; btnView.Title = btnCell.Text; btnView.ToolTip = btnCell.Tooltip; btnView.Enabled = btnCell.Enabled; btnView.Activated += (sender, e) => btnCell.Activated(); //btnView.Image = return(btnView); case TypeCell.PopUp: var btnPCell = (IPopUpButtonCell)cell; //var btnP = NSPopUpButton.CreateButton(btnPCell.Text, btnPCell.Activated); var btnPView = new NSPopUpButton(new CGRect(0, 0, 80, 16), true); btnPView.SetButtonType(NSButtonType.MomentaryPushIn); btnPView.BezelStyle = NSBezelStyle.Rounded; btnPView.PullsDown = false; btnPView.ToolTip = btnPCell.Tooltip; btnPView.Enabled = btnPCell.Enabled; btnPView.Menu.RemoveAllItems(); foreach (var title in btnPCell.MenuTitles) { btnPView.AddItem(title); } btnPView.Activated += (sender, e) => { btnPCell.IndexOfSelectedItem = (int)btnPView.IndexOfSelectedItem; if (btnPCell.SelectItem != null) { btnPCell.SelectItem((int)btnPView.IndexOfSelectedItem); } else { btnPCell.Activated(); } }; return(btnPView); case TypeCell.Checkbox: var ckbCell = (ICheckboxCell)cell; var tblCellView = new NSTableCellView(); tblCellView.TextField = new NSTextField(new CGRect(20, 0, 400, 16)); //tblCellView.Identifier = CellIdentifier; tblCellView.TextField.BackgroundColor = NSColor.Clear; tblCellView.TextField.Bordered = false; tblCellView.TextField.Editable = false; tblCellView.TextField.Selectable = false; tblCellView.TextField.StringValue = cellValue.Text; tblCellView.TextField.ToolTip = cellValue.Tooltip; tblCellView.AddSubview(tblCellView.TextField); var checkBox = new NSButton(new CGRect(5, 0, 16, 16)); checkBox.SetButtonType(NSButtonType.Switch); checkBox.Enabled = ckbCell.Enabled; checkBox.AllowsMixedState = ckbCell.AllowMixedState; if (ckbCell.State == null) { checkBox.State = NSCellStateValue.Mixed; } else if (ckbCell.State == true) { checkBox.State = NSCellStateValue.On; } else if (ckbCell.State == false) { checkBox.State = NSCellStateValue.Off; } checkBox.Enabled = ckbCell.Enabled; checkBox.Activated += (sender, e) => { var ckb = (NSButton)sender; bool?state = null; if (ckb.State == NSCellStateValue.Mixed) { state = null; } else if (ckb.State == NSCellStateValue.On) { state = true; } else if (ckb.State == NSCellStateValue.Off) { state = false; } ckbCell.State = state; if (ckbCell.StateChanged != null) { ckbCell.StateChanged(state); } else { ckbCell.Activated(); } }; tblCellView.AddSubview(checkBox); return(tblCellView); } throw new System.NotImplementedException("Do not have implementation"); }
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); }
public override NSView GetViewForItem(NSTableView tableView, NSTableColumn tableColumn, nint row) { NSTableCellView view = (NSTableCellView)tableView.MakeView(tableColumn.Title, this); view = new NSTableCellView(); // Configure the view view.Identifier = tableColumn.Title; // Take action based on title switch (tableColumn.Title) { case "Attribute": view.TextField = new NSTextField(new CGRect(0, 0, 250, 17)); ConfigureTextField(view, row); break; case "Value": view.TextField = new NSTextField(new CGRect(0, 0, 250, 17)); ConfigureTextField(view, row); break; case "Syntax": view.TextField = new NSTextField(new CGRect(16, 0, 200, 17)); ConfigureTextField(view, row); var button = new NSButton(new CGRect(0, 0, 16, 16)); button.SetButtonType(NSButtonType.MomentaryLightButton); button.Image = new NSImage("Question.png"); button.Title = ""; button.Tag = row; // Wireup events button.Activated += (sender, e) => { // Get button and product var btn = sender as NSButton; var name = _ds.displayAttrDTOList[(int)btn.Tag].Name; var type = _ds.serverDTO.Connection.SchemaManager.GetAttributeType(name); AttributeHelpDTO attrHelp = null; if (type.AttributeSyntax != null) { VMDirCommonEnvironment.Instance.AttrHelpDict.TryGetValue(type.AttributeSyntax, out attrHelp); } SyntaxHelpWindowController shwc = new SyntaxHelpWindowController(attrHelp); NSApplication.SharedApplication.BeginSheet(shwc.Window, _controller.Window, () => { }); try { NSApplication.SharedApplication.RunModalForWindow(shwc.Window); } finally { _controller.Window.EndSheet(shwc.Window); shwc.Dispose(); } }; view.AddSubview(button); break; } switch (tableColumn.Title) { case "Attribute": view.TextField.StringValue = _ds.displayAttrDTOList[(int)row].Name; view.TextField.Tag = row; break; case "Value": var val = _ds.displayAttrDTOList[(int)row].Value == null ? string.Empty : _ds.displayAttrDTOList[(int)row].Value; var type = _ds.displayAttrDTOList[(int)row].AttrSyntaxDTO; if (type != null && type.Type.Equals("Generalized Time")) { val = Utilities.ConvertGeneralizedTimeIntoReadableFormat(val); } view.TextField.StringValue = val; view.TextField.Tag = row; if (_ds.displayAttrDTOList[(int)row].Dirty) { view.TextField.BackgroundColor = NSColor.Orange; } break; case "Syntax": view.TextField.StringValue = _ds.displayAttrDTOList[(int)row].AttrSyntaxDTO.Type == null ? string.Empty : _ds.displayAttrDTOList[(int)row].AttrSyntaxDTO.Type; foreach (NSView subview in view.Subviews) { var bt = subview as NSButton; if (bt != null) { bt.Tag = row; } } break; } return(view); }
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; }
public override NSView GetViewForItem(NSTableView tableView, NSTableColumn tableColumn, nint row) { NSTableCellView view = (NSTableCellView)tableView.MakeView(tableColumn.Title, this); //if (view == null) //Need to recreate entire table if new books added if (true) { view = new NSTableCellView(); // Configure the view view.Identifier = tableColumn.Title; // Take action based on title switch (tableColumn.Title) { case "Media": ////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 "Title": view.TextField = new NSTextField(new CGRect(0, 0, 400, 16)); ConfigureTextField(view, row); break; case "Creator": view.TextField = new NSTextField(new CGRect(0, 0, 400, 16)); ConfigureTextField(view, row); break; case "Language": view.TextField = new NSTextField(new CGRect(0, 0, 400, 16)); ConfigureTextField(view, row); break; case "Rating": view.TextField = new NSTextField(new CGRect(0, 0, 400, 16)); ConfigureTextField(view, row); break; case "Date": view.TextField = new NSTextField(new CGRect(0, 0, 400, 16)); ConfigureTextField(view, row); break; case "Completion": view.TextField = new NSTextField(new CGRect(0, 0, 400, 16)); ConfigureTextField(view, row); break; case "Delete": // 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 record = DataSource.MediaRecords[(int)btn.Tag]; // Configure alert var alert = new NSAlert() { AlertStyle = NSAlertStyle.Informational, InformativeText = $"Are you sure you want to delete the {record.Media.ToLower()} {record.Title} by {record.Creator}? This operation cannot be undone.", MessageText = $"Delete {record.Title}?", }; alert.AddButton("Cancel"); alert.AddButton("Delete"); alert.BeginSheetForResponse(Controller.View.Window, (result) => { // Should we delete the requested row? if (result == 1001) { // Delete record from the database and remove the given row from the dataset var connection = GetDatabaseConnection(); DataSource.MediaRecords[(int)btn.Tag].Delete(connection); DataSource.MediaRecords.RemoveAt((int)btn.Tag); //Controller.ReloadMediaTable(); Controller.SearchMedia(); } }); }; // Add to view view.AddSubview(button); break; } } // Setup view based on the column selected switch (tableColumn.Title) { case "Media": view.TextField.StringValue = DataSource.MediaRecords[(int)row].Media; break; case "Title": view.TextField.StringValue = DataSource.MediaRecords[(int)row].Title; break; case "Creator": view.TextField.StringValue = DataSource.MediaRecords[(int)row].Creator; break; case "Language": view.TextField.StringValue = DataSource.MediaRecords[(int)row].Language; break; case "Rating": int rating = DataSource.MediaRecords[(int)row].Rating; if (rating == 0) { view.TextField.StringValue = ""; } else { view.TextField.StringValue = rating.ToString(); } break; case "Date": view.TextField.StringValue = DataSource.MediaRecords[(int)row].Date; break; case "Completion": view.TextField.StringValue = DataSource.MediaRecords[(int)row].Status; break; case "Delete": foreach (NSView subview in view.Subviews) { var btn = subview as NSButton; if (btn != null) { btn.Tag = row; } } break; } return(view); }