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

ResourceOutlineViewDelegate.cs « Custom « Controls « Xamarin.PropertyEditing.Mac - github.com/xamarin/Xamarin.PropertyEditing.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 4df996be6811c05eeb8f9d1173e4abeb443595b7 (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
using System;
using AppKit;
using CoreGraphics;
using Foundation;
using Xamarin.PropertyEditing.Drawing;
using Xamarin.PropertyEditing.ViewModels;

namespace Xamarin.PropertyEditing.Mac
{
	internal class ResourceOutlineViewDelegate : NSOutlineViewDelegate
	{
		private const string labelIdentifier = "label";
		private const string resourceIdentifier = "resource";

		public override NSView GetView (NSOutlineView outlineView, NSTableColumn tableColumn, NSObject item)
		{
			var facade = item as NSObjectFacade;
			var resource = facade?.Target as Resource;
			switch (tableColumn.Identifier) {
				case ResourceOutlineView.ResourcePreviewColId:
					var cbv = (CommonBrushView)outlineView.MakeView (resourceIdentifier, this);
					if (cbv == null) {
						cbv = new CommonBrushView {
							Identifier = resourceIdentifier,
							Frame = new CGRect (0, 0, 30, 10),
						};
					}

					var commonBrush = BrushPropertyViewModel.GetCommonBrushForResource (resource);
					if (commonBrush != null)
						cbv.Brush = commonBrush;

					return cbv;

				case ResourceOutlineView.ResourceNameColId:
				default:
					var utf = (UnfocusableTextField)outlineView.MakeView (labelIdentifier, this);
					if (utf == null) {
						utf = new UnfocusableTextField {
							Identifier = labelIdentifier,
						};
					}
					utf.StringValue = resource.Name;
					return utf;
			}
		}


		public override nfloat GetRowHeight (NSOutlineView outlineView, NSObject item)
		{
			return PropertyEditorControl.DefaultControlHeight;
		}
	}
}