Welcome to mirror list, hosted at ThFree Co, Russian Federation.

ResourceOutlineView.cs « Custom « Controls « Xamarin.PropertyEditing.Mac - github.com/xamarin/Xamarin.PropertyEditing.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 7437ae275740fe0e856aae59ae001c1dfa378b80 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
using System;
using AppKit;
using CoreGraphics;
using Foundation;
using Xamarin.PropertyEditing.ViewModels;

namespace Xamarin.PropertyEditing.Mac
{
	internal class ResourceOutlineView : NSOutlineView
	{
		internal const string ResourcePreviewColId = "Preview";
		internal const string ResourceNameColId = "Name";

		public ResourceOutlineView ()
		{
			Initialize ();
			RowHeight = 24;
		}

		// Called when created from unmanaged code
		public ResourceOutlineView (IntPtr handle) : base (handle)
		{
		}

		// Called when created directly from a XIB file
		[Export ("initWithCoder:")]
		public ResourceOutlineView (NSCoder coder) : base (coder)
		{
		}

		public void Initialize ()
		{
			var nameColumn = new NSTableColumn (ResourceNameColId) {
				Title = Properties.Resources.ColumnResourceName,
				Width = 150,
			};
			AddColumn (nameColumn);

			var previewColumn = new NSTableColumn (ResourcePreviewColId) {
				Title = Properties.Resources.ColumnResourcePreview,
				Width = 150,
			};
			AddColumn (previewColumn);

			HeaderView = null;
		}

		public override bool ValidateProposedFirstResponder (NSResponder responder, NSEvent forEvent)
		{
			return true;
		}

		private ResourceSelectorViewModel viewModel;
		public ResourceSelectorViewModel ViewModel
		{
			get => this.viewModel;
			set
			{
				this.viewModel = value;
				DataSource = new ResourceDataSource (viewModel);
			}
		}
	}
}