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

github.com/xamarin/Xamarin.PropertyEditing.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Maupin <ermaup@microsoft.com>2019-01-03 22:44:37 +0300
committerEric Maupin <ermaup@microsoft.com>2019-01-11 23:19:25 +0300
commit71ad75860e1c5b6c33163d390988dbfbf409b4ac (patch)
tree80f6ed1ac0a1a0face888e3481f802f4d328a312 /Xamarin.PropertyEditing.Mac/Controls/RequestResource
parent104acbcc9c62e1a90e9e43cb7630583cb2b49ca4 (diff)
[mac] Revamp theming
This commit: - Drops outdated CG* editors - Drops ThemeManager - Introduces IHostResourceProvider - Moves all images to new API - Starts implementing colors
Diffstat (limited to 'Xamarin.PropertyEditing.Mac/Controls/RequestResource')
-rw-r--r--Xamarin.PropertyEditing.Mac/Controls/RequestResource/RequestResourcePanel.cs14
-rw-r--r--Xamarin.PropertyEditing.Mac/Controls/RequestResource/RequestResourceView.cs20
-rw-r--r--Xamarin.PropertyEditing.Mac/Controls/RequestResource/ResourceTableDelegate.cs22
3 files changed, 32 insertions, 24 deletions
diff --git a/Xamarin.PropertyEditing.Mac/Controls/RequestResource/RequestResourcePanel.cs b/Xamarin.PropertyEditing.Mac/Controls/RequestResource/RequestResourcePanel.cs
index 4907d2a..2a3143b 100644
--- a/Xamarin.PropertyEditing.Mac/Controls/RequestResource/RequestResourcePanel.cs
+++ b/Xamarin.PropertyEditing.Mac/Controls/RequestResource/RequestResourcePanel.cs
@@ -18,7 +18,8 @@ namespace Xamarin.PropertyEditing.Mac
private NSTableView resourceTable;
private ResourceTableDataSource dataSource;
- private ResourceSelectorViewModel viewModel;
+ private readonly ResourceSelectorViewModel viewModel;
+
public ResourceSelectorViewModel ViewModel => this.viewModel;
private SimpleCollectionView collectionView => this.viewModel.Resources as SimpleCollectionView;
public Resource SelectedResource {
@@ -38,11 +39,14 @@ namespace Xamarin.PropertyEditing.Mac
private object selectedValue;
- public RequestResourcePanel (ResourceSelectorViewModel viewModel, object value)
+ public RequestResourcePanel (IHostResourceProvider hostResources, ResourceSelectorViewModel viewModel, object value)
{
+ if (hostResources == null)
+ throw new ArgumentNullException (nameof (hostResources));
+
this.viewModel = viewModel;
this.viewModel.PropertyChanged += OnPropertyChanged;
- Initialize (value);
+ Initialize (hostResources, value);
}
private void OnPropertyChanged (object sender, PropertyChangedEventArgs e)
@@ -58,7 +62,7 @@ namespace Xamarin.PropertyEditing.Mac
}
}
- private void Initialize (object selectedValue)
+ private void Initialize (IHostResourceProvider hostResources, object selectedValue)
{
this.selectedValue = selectedValue;
Frame = new CGRect (10, 35, 630, 305);
@@ -80,7 +84,7 @@ namespace Xamarin.PropertyEditing.Mac
};
this.dataSource = new ResourceTableDataSource (viewModel);
- var resourceTableDelegate = new ResourceTableDelegate (dataSource);
+ var resourceTableDelegate = new ResourceTableDelegate (hostResources, dataSource);
resourceTableDelegate.ResourceSelected += (sender, e) => {
this.previewPanel.SelectedResource = SelectedResource;
diff --git a/Xamarin.PropertyEditing.Mac/Controls/RequestResource/RequestResourceView.cs b/Xamarin.PropertyEditing.Mac/Controls/RequestResource/RequestResourceView.cs
index 8a85e1d..f810428 100644
--- a/Xamarin.PropertyEditing.Mac/Controls/RequestResource/RequestResourceView.cs
+++ b/Xamarin.PropertyEditing.Mac/Controls/RequestResource/RequestResourceView.cs
@@ -19,7 +19,8 @@ namespace Xamarin.PropertyEditing.Mac
}
}
- internal class RequestResourceView : BasePopOverViewModelControl
+ internal class RequestResourceView
+ : BasePopOverViewModelControl
{
NSSearchField searchResources;
NSSegmentedControl segmentedControl;
@@ -43,7 +44,8 @@ namespace Xamarin.PropertyEditing.Mac
}
}
- public RequestResourceView (PropertyViewModel propertyViewModel) : base (propertyViewModel, Properties.Resources.SelectResourceTitle, "resource-editor-32")
+ public RequestResourceView (IHostResourceProvider hostResources, PropertyViewModel propertyViewModel)
+ : base (hostResources, propertyViewModel, Properties.Resources.SelectResourceTitle, "resource-editor-32")
{
Initialize (propertyViewModel);
}
@@ -77,9 +79,9 @@ namespace Xamarin.PropertyEditing.Mac
var resourceSelector = resourceSelectorPropertyInfo.GetValue (propertyViewModel) as ResourceSelectorViewModel;
if (resourceSelector != null) {
- this.resourceSelectorPanel = new RequestResourcePanel (resourceSelector, resourceValue);
+ this.resourceSelectorPanel = new RequestResourcePanel (HostResources, resourceSelector, resourceValue);
} else {
- this.resourceSelectorPanel = new RequestResourcePanel (new ResourceSelectorViewModel (propertyViewModel.TargetPlatform.ResourceProvider, propertyViewModel.Editors.Select (ed => ed.Target), propertyViewModel.Property), resourceValue);
+ this.resourceSelectorPanel = new RequestResourcePanel (HostResources, new ResourceSelectorViewModel (propertyViewModel.TargetPlatform.ResourceProvider, propertyViewModel.Editors.Select (ed => ed.Target), propertyViewModel.Property), resourceValue);
}
this.resourceSelectorPanel.ResourceSelected += (sender, e) => {
propertyViewModel.Resource = this.resourceSelectorPanel.SelectedResource;
@@ -95,21 +97,21 @@ namespace Xamarin.PropertyEditing.Mac
switch (this.segmentedControl.SelectedSegment) {
case 0:
this.resourceSelectorPanel.ViewModel.ShowBothResourceTypes = true;
- this.segmentedControl.SetImage (PropertyEditorPanel.ThemeManager.GetImageForTheme ("resource-editor-16"), 2);
+ this.segmentedControl.SetImage (HostResources.GetNamedImage ("resource-editor-16"), 2);
break;
case 1:
this.resourceSelectorPanel.ViewModel.ShowOnlyLocalResources = true;
- this.segmentedControl.SetImage (PropertyEditorPanel.ThemeManager.GetImageForTheme ("resource-editor-16"), 2);
+ this.segmentedControl.SetImage (HostResources.GetNamedImage ("resource-editor-16"), 2);
break;
case 2:
this.resourceSelectorPanel.ViewModel.ShowOnlySystemResources = true;
- this.segmentedControl.SetImage (PropertyEditorPanel.ThemeManager.GetImageForTheme ("resource-editor-16", true), 2);
+ this.segmentedControl.SetImage (HostResources.GetNamedImage ("resource-editor-16~sel"), 2);
break;
}
this.resourceSelectorPanel.ReloadData ();
});
- this.segmentedControl.SetImage (PropertyEditorPanel.ThemeManager.GetImageForTheme ("resource-editor-16"), 2);
+ this.segmentedControl.SetImage (HostResources.GetNamedImage ("resource-editor-16"), 2);
this.segmentedControl.Frame = new CGRect ((FrameWidthThird - (segmentedControl.Bounds.Width) / 2), 5, (Frame.Width - (FrameWidthThird)) - 10, 24);
this.segmentedControl.Font = NSFont.FromFontName (PropertyEditorControl.DefaultFontName, PropertyEditorControl.DefaultFontSize);
this.segmentedControl.TranslatesAutoresizingMaskIntoConstraints = false;
@@ -133,8 +135,6 @@ namespace Xamarin.PropertyEditing.Mac
AddSubview (this.showPreviewImage);
- this.Appearance = PropertyEditorPanel.ThemeManager.CurrentAppearance;
-
OnSearchResourcesChanged(null, null);
RepositionControls ();
diff --git a/Xamarin.PropertyEditing.Mac/Controls/RequestResource/ResourceTableDelegate.cs b/Xamarin.PropertyEditing.Mac/Controls/RequestResource/ResourceTableDelegate.cs
index 9ea3a19..b712edf 100644
--- a/Xamarin.PropertyEditing.Mac/Controls/RequestResource/ResourceTableDelegate.cs
+++ b/Xamarin.PropertyEditing.Mac/Controls/RequestResource/ResourceTableDelegate.cs
@@ -10,8 +10,6 @@ namespace Xamarin.PropertyEditing.Mac
internal class ResourceTableDelegate
: NSTableViewDelegate
{
- private ResourceTableDataSource datasource;
-
const string iconIdentifier = "icon";
const string typeIdentifier = "type";
const string nameIdentifier = "name";
@@ -19,11 +17,13 @@ namespace Xamarin.PropertyEditing.Mac
public event EventHandler ResourceSelected;
- private nint previousRow = -1;
-
- public ResourceTableDelegate (ResourceTableDataSource resourceTableDatasource)
+ public ResourceTableDelegate (IHostResourceProvider hostResources, ResourceTableDataSource resourceTableDatasource)
{
+ if (hostResources == null)
+ throw new ArgumentNullException (nameof (hostResources));
+
this.datasource = resourceTableDatasource;
+ this.hostResources = hostResources;
}
// the table is looking for this method, picks it up automagically
@@ -38,7 +38,7 @@ namespace Xamarin.PropertyEditing.Mac
var iconView = (NSImageView)tableView.MakeView (iconIdentifier, this);
if (iconView == null) {
iconView = new NSImageView {
- Image = PropertyEditorPanel.ThemeManager.GetImageForTheme ("resource-editor-32"),
+ Image = this.hostResources.GetNamedImage ("resource-editor-32"),
ImageScaling = NSImageScale.None,
Identifier = iconIdentifier,
};
@@ -95,18 +95,22 @@ namespace Xamarin.PropertyEditing.Mac
if (previousRow != -1
&& previousRow < tableView.RowCount
&& tableView.GetView (0, previousRow, false) is NSImageView previousIconColumn) {
- previousIconColumn.Image = PropertyEditorPanel.ThemeManager.GetImageForTheme ("resource-editor-32");
+ previousIconColumn.Image = this.hostResources.GetNamedImage ("resource-editor-32");
}
if (tableView.SelectedRow != -1
&& tableView.GetView (0, tableView.SelectedRow, false) is NSImageView selectedIconColumn) {
- selectedIconColumn.Image = PropertyEditorPanel.ThemeManager.GetImageForTheme ("resource-editor-32", true);
+ selectedIconColumn.Image = this.hostResources.GetNamedImage ("resource-editor-32~sel");
previousRow = tableView.SelectedRow;
}
}
ResourceSelected?.Invoke (this, EventArgs.Empty);
}
+ private readonly IHostResourceProvider hostResources;
+ private readonly ResourceTableDataSource datasource;
+ private nint previousRow = -1;
+
private NSView MakeValueView (Resource resource, NSTableView tableView)
{
var view = (NSView)tableView.MakeView (valueIdentifier, this);
@@ -123,7 +127,7 @@ namespace Xamarin.PropertyEditing.Mac
return view;
}
- NSView GetValueView (Type representationType)
+ private NSView GetValueView (Type representationType)
{
Type[] genericArgs = null;
Type valueRenderType;