blob: e2e03f023a5b80acd9af51ab27a5c3a34ac62dac (
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
|
using System;
using AppKit;
using CoreGraphics;
using Foundation;
using Xamarin.PropertyEditing.Drawing;
using Xamarin.PropertyEditing.ViewModels;
namespace Xamarin.PropertyEditing.Mac
{
internal class ResourceOutlineViewDelegate
: NSOutlineViewDelegate
{
public ResourceOutlineViewDelegate (IHostResourceProvider hostResource)
{
if (hostResource == null)
throw new ArgumentNullException (nameof (hostResource));
this.hostResources = hostResource;
}
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 (this.hostResources) {
Identifier = resourceIdentifier,
Frame = new CGRect (0, 0, 30, 18),
AutoresizingMask = NSViewResizingMask.WidthSizable
};
}
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;
}
}
private const string labelIdentifier = "label";
private const string resourceIdentifier = "resource";
private readonly IHostResourceProvider hostResources;
}
}
|