private void tv_AfterSelect(object sender, TreeViewEventArgs e) { tv.SelectedNode = e.Node; ResourceSelected?.Invoke(this, new ResourceEventArgs((e.Node as WebresourceNode)?.Resource)); ResourceDisplayRequested?.Invoke(this, new ResourceEventArgs((e.Node as WebresourceNode)?.Resource)); }
public override void SelectionDidChange(NSNotification notification) { if (notification.Object is NSTableView tableView) { if (previousRow != -1 && previousRow < tableView.RowCount && tableView.GetView(0, previousRow, false) is NSImageView previousIconColumn) { previousIconColumn.Image = this.hostResources.GetNamedImage("pe-resource-editor-32"); } if (tableView.SelectedRow != -1 && tableView.GetView(0, tableView.SelectedRow, false) is NSImageView selectedIconColumn) { selectedIconColumn.Image = this.hostResources.GetNamedImage("pe-resource-editor-32~sel"); previousRow = tableView.SelectedRow; } } ResourceSelected?.Invoke(this, EventArgs.Empty); }
private void Initialize(IHostResourceProvider hostResources, object selectedValue) { this.selectedValue = selectedValue; Frame = new CGRect(10, 35, 630, 305); var FrameHeightHalf = (Frame.Height - 32) / 2; var FrameWidthHalf = (Frame.Width - 32) / 2; var FrameWidthThird = (Frame.Width - 32) / 3; this.progressIndicator = new NSProgressIndicator(new CGRect(FrameWidthThird, FrameHeightHalf, 32, 32)) { Hidden = true, Style = NSProgressIndicatorStyle.Spinning, TranslatesAutoresizingMaskIntoConstraints = false, }; AddSubview(this.progressIndicator); this.resourceTable = new FirstResponderTableView { AutoresizingMask = NSViewResizingMask.WidthSizable, HeaderView = null, }; this.dataSource = new ResourceTableDataSource(viewModel); var resourceTableDelegate = new ResourceTableDelegate(hostResources, dataSource); resourceTableDelegate.ResourceSelected += (sender, e) => { this.previewPanel.SelectedResource = SelectedResource; this.selectedValue = BrushPropertyViewModel.GetCommonBrushForResource(SelectedResource); ResourceSelected?.Invoke(this, EventArgs.Empty); }; this.resourceTable.Delegate = resourceTableDelegate; this.resourceTable.DataSource = dataSource; NSTableColumn resourceImages = new NSTableColumn(ResourceImageColId) { Title = Properties.Resources.ResourceTableImageColumnTitle, Width = 32 }; this.resourceTable.AddColumn(resourceImages); NSTableColumn resourceTypes = new NSTableColumn(ResourceTypeColId) { Title = Properties.Resources.ResourceTableTypeColumnTitle, Width = 150 }; this.resourceTable.AddColumn(resourceTypes); NSTableColumn resourceName = new NSTableColumn(ResourceNameColId) { Title = Properties.Resources.ResourceTableNameColumnTitle, Width = 150 }; resourceTable.AddColumn(resourceName); NSTableColumn resourceValue = new NSTableColumn(ResourceValueColId) { Title = Properties.Resources.ResourceTableValueColumnTitle, Width = 45 }; this.resourceTable.AddColumn(resourceValue); this.resourceTable.DoubleClick += (object sender, EventArgs e) => { DoubleClicked?.Invoke(this, EventArgs.Empty); }; // create a table view and a scroll view this.tableContainer = new NSScrollView(new CGRect(0, 0, resourceTable.TableColumns()[0].Width + resourceTable.TableColumns()[1].Width + resourceTable.TableColumns()[2].Width + 10, Frame.Height)) { TranslatesAutoresizingMaskIntoConstraints = false, }; this.tableContainer.DocumentView = resourceTable; AddSubview(this.tableContainer); this.previewPanel = new RequestResourcePreviewPanel(hostResources, new CGRect(Frame.Width - FrameWidthThird, 0, FrameWidthThird, Frame.Height)); AddSubview(this.previewPanel); this.AddConstraints(new[] { NSLayoutConstraint.Create(this.tableContainer, NSLayoutAttribute.Width, NSLayoutRelation.Equal, this, NSLayoutAttribute.Width, 1f, -190f), NSLayoutConstraint.Create(this.tableContainer, NSLayoutAttribute.Height, NSLayoutRelation.Equal, this, NSLayoutAttribute.Height, 1f, 0f), }); ReloadData(); }