Skip to content
This repository was archived by the owner on Sep 25, 2024. It is now read-only.

Commit 01620ba

Browse files
authored
Merge pull request #516 from xamarin/dominique-UniqueResourceNames
Add pe- prefix to all image resources.
2 parents 9c1e613 + e0be9d9 commit 01620ba

File tree

168 files changed

+54
-186
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

168 files changed

+54
-186
lines changed

Xamarin.PropertyEditing.Mac.Standalone/Xamarin.PropertyEditing.Mac.Standalone.csproj

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,4 +114,19 @@
114114
</ProjectReference>
115115
</ItemGroup>
116116
<Import Project="$(MSBuildExtensionsPath)\Xamarin\Mac\Xamarin.Mac.CSharp.targets" />
117+
<ItemGroup>
118+
<PropertyEditingResource Include="PropertyEditingResource\**\*" />
119+
</ItemGroup>
120+
<Target Name="AfterBuild">
121+
<ItemGroup>
122+
<PropertyEditingResourceBundlePath Include="$(SolutionDir)\Xamarin.PropertyEditing.Mac\PropertyEditingResource\**\*" />
123+
</ItemGroup>
124+
<Copy
125+
SourceFiles="@(PropertyEditingResourceBundlePath)"
126+
DestinationFiles="@(PropertyEditingResourceBundlePath->'$(OutputPath)\$(AssemblyName).app\Contents\MonoBundle\PropertyEditingResource.bundle\%(RecursiveDir)%(Filename)%(Extension)')"
127+
SkipUnchangedFiles="true"
128+
OverwriteReadOnlyFiles="true"
129+
Retries="3"
130+
RetryDelayMilliseconds="300" />
131+
</Target>
117132
</Project>

Xamarin.PropertyEditing.Mac/Controls/BaseEditorControl.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ public BaseEditorControl (IHostResourceProvider hostResources)
7777

7878
public override void ViewDidChangeEffectiveAppearance ()
7979
{
80-
this.actionButton.Image = this.actionButton.Enabled ? HostResources.GetNamedImage ("action-warning-16") : null;
80+
this.actionButton.Image = this.actionButton.Enabled ? HostResources.GetNamedImage ("pe-action-warning-16") : null;
8181
}
8282

8383
protected IHostResourceProvider HostResources
@@ -93,7 +93,7 @@ protected void SetErrors (IEnumerable errors)
9393
this.actionButton.Hidden = !this.actionButton.Enabled;
9494

9595
// Using NSImageName.Caution for now, we can change this later at the designers behest
96-
this.actionButton.Image = this.actionButton.Enabled ? HostResources.GetNamedImage ("action-warning-16") : null;
96+
this.actionButton.Image = this.actionButton.Enabled ? HostResources.GetNamedImage ("pe-action-warning-16") : null;
9797
}
9898

9999
void NotifyActionButtonClicked ()

Xamarin.PropertyEditing.Mac/Controls/Custom/BrushTabViewController.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -94,31 +94,31 @@ public override void OnViewModelChanged (BrushPropertyViewModel oldModel)
9494
solid.ViewModel = ViewModel;
9595
item.ViewController = solid;
9696
item.ToolTip = Properties.Resources.SolidBrush;
97-
image = "property-brush-solid-16";
97+
image = "pe-property-brush-solid-16";
9898
break;
9999

100100
case CommonBrushType.MaterialDesign:
101101
var material = new MaterialBrushEditorViewController (HostResources);
102102
material.ViewModel = ViewModel;
103103
item.ViewController = material;
104104
item.ToolTip = Properties.Resources.MaterialDesignColorBrush;
105-
image = "property-brush-palette-16";
105+
image = "pe-property-brush-palette-16";
106106
break;
107107

108108
case CommonBrushType.Resource:
109109
this.resource = new ResourceBrushViewController (HostResources);
110110
this.resource.ViewModel = ViewModel;
111111
item.ViewController = this.resource;
112112
item.ToolTip = Properties.Resources.ResourceBrush;
113-
image = "property-brush-resources-16";
113+
image = "pe-property-brush-resources-16";
114114
break;
115115

116116
case CommonBrushType.Gradient:
117117
var gradient = new EmptyBrushEditorViewController ();
118118
gradient.ViewModel = ViewModel;
119119
item.ViewController = gradient;
120120
item.ToolTip = item.Label;
121-
image = "property-brush-gradient-16";
121+
image = "pe-property-brush-gradient-16";
122122
break;
123123

124124
default:
@@ -127,7 +127,7 @@ public override void OnViewModelChanged (BrushPropertyViewModel oldModel)
127127
none.ViewModel = ViewModel;
128128
item.ViewController = none;
129129
item.ToolTip = Properties.Resources.NoBrush;
130-
image = "property-brush-none-16";
130+
image = "pe-property-brush-none-16";
131131
break;
132132
}
133133

Xamarin.PropertyEditing.Mac/Controls/Custom/PropertyButton.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public PropertyButton (IHostResourceProvider hostResources)
4040
AccessibilityTitle = LocalizationResources.AccessibilityPropertiesButton;
4141
AccessibilityHelp = LocalizationResources.AccessibilityPropertiesButtonDescription;
4242
Enabled = true;
43-
Image = this.hostResources.GetNamedImage ("property-button-default-mac-10");
43+
Image = this.hostResources.GetNamedImage ("pe-property-button-default-mac-10");
4444
ImageScaling = NSImageScale.None;
4545
ToolTip = Properties.Resources.Default;
4646

@@ -125,27 +125,27 @@ private void ToggleFocusImage (bool focused = false)
125125

126126
switch (viewModel.ValueSource) {
127127
case ValueSource.Binding:
128-
Image = focused ? this.hostResources.GetNamedImage ("property-button-bound-mac-active-10") : this.hostResources.GetNamedImage ("property-button-bound-mac-10");
128+
Image = focused ? this.hostResources.GetNamedImage ("pe-property-button-bound-mac-active-10") : this.hostResources.GetNamedImage ("pe-property-button-bound-mac-10");
129129
break;
130130

131131
case ValueSource.Default:
132-
Image = focused ? this.hostResources.GetNamedImage ("property-button-default-mac-active-10") : this.hostResources.GetNamedImage ("property-button-default-mac-10");
132+
Image = focused ? this.hostResources.GetNamedImage ("pe-property-button-default-mac-active-10") : this.hostResources.GetNamedImage ("pe-property-button-default-mac-10");
133133
break;
134134

135135
case ValueSource.Local:
136-
Image = focused ? this.hostResources.GetNamedImage ("property-button-local-mac-active-10") : this.hostResources.GetNamedImage ("property-button-local-mac-10");
136+
Image = focused ? this.hostResources.GetNamedImage ("pe-property-button-local-mac-active-10") : this.hostResources.GetNamedImage ("pe-property-button-local-mac-10");
137137
break;
138138

139139
case ValueSource.Inherited:
140-
Image = focused ? this.hostResources.GetNamedImage ("property-button-inherited-mac-active-10") : this.hostResources.GetNamedImage ("property-button-inherited-mac-10");
140+
Image = focused ? this.hostResources.GetNamedImage ("pe-property-button-inherited-mac-active-10") : this.hostResources.GetNamedImage ("pe-property-button-inherited-mac-10");
141141
break;
142142

143143
case ValueSource.Resource:
144-
Image = focused ? this.hostResources.GetNamedImage ("property-button-inherited-mac-active-10") : this.hostResources.GetNamedImage ("property-button-inherited-mac-10");
144+
Image = focused ? this.hostResources.GetNamedImage ("pe-property-button-inherited-mac-active-10") : this.hostResources.GetNamedImage ("pe-property-button-inherited-mac-10");
145145
break;
146146

147147
case ValueSource.Unset:
148-
Image = focused ? this.hostResources.GetNamedImage ("property-button-default-mac-active-10") : this.hostResources.GetNamedImage ("property-button-default-mac-10");
148+
Image = focused ? this.hostResources.GetNamedImage ("pe-property-button-default-mac-active-10") : this.hostResources.GetNamedImage ("pe-property-button-default-mac-10");
149149
break;
150150

151151
default:

Xamarin.PropertyEditing.Mac/Controls/Custom/SpinnerButton.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public override void ViewDidChangeEffectiveAppearance ()
4040

4141
private readonly IHostResourceProvider hostResources;
4242
private bool isMouseOver;
43-
private string imageBase = "stepper-";
43+
private string imageBase = "pe-stepper-";
4444

4545
private NSImage image;
4646
private NSImage mouseOverImage;

Xamarin.PropertyEditing.Mac/Controls/CustomExpressionView.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ internal class CustomExpressionView : BasePopOverViewModelControl
1515
PropertyInfo customExpressionPropertyInfo;
1616

1717
public CustomExpressionView (IHostResourceProvider hostResources, PropertyViewModel viewModel)
18-
: base (hostResources, viewModel, Properties.Resources.CustomExpression, "custom-expression-32")
18+
: base (hostResources, viewModel, Properties.Resources.CustomExpression, "pe-custom-expression-32")
1919
{
2020
Frame = new CGRect (CGPoint.Empty, new CGSize (250, 80));
2121

Xamarin.PropertyEditing.Mac/Controls/ErrorMessageView.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public ErrorMessageView (IHostResourceProvider hostResources, IEnumerable errors
2222

2323
var iconView = new NSButton (new CGRect (5, Frame.Height - 25, DefaultIconButtonSize, DefaultIconButtonSize)) {
2424
Bordered = false,
25-
Image = hostResources.GetNamedImage ("action-warning-16"),
25+
Image = hostResources.GetNamedImage ("pe-action-warning-16"),
2626
Title = string.Empty,
2727
TranslatesAutoresizingMaskIntoConstraints = false,
2828
};

Xamarin.PropertyEditing.Mac/Controls/RequestResource/RequestResourceView.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public bool ShowPreview
4545
}
4646

4747
public RequestResourceView (IHostResourceProvider hostResources, PropertyViewModel propertyViewModel)
48-
: base (hostResources, propertyViewModel, Properties.Resources.SelectResourceTitle, "resource-editor-32")
48+
: base (hostResources, propertyViewModel, Properties.Resources.SelectResourceTitle, "pe-resource-editor-32")
4949
{
5050
Initialize (propertyViewModel);
5151
}
@@ -97,21 +97,21 @@ private void Initialize (PropertyViewModel propertyViewModel)
9797
switch (this.segmentedControl.SelectedSegment) {
9898
case 0:
9999
this.resourceSelectorPanel.ViewModel.ShowBothResourceTypes = true;
100-
this.segmentedControl.SetImage (HostResources.GetNamedImage ("resource-editor-16"), 2);
100+
this.segmentedControl.SetImage (HostResources.GetNamedImage ("pe-resource-editor-16"), 2);
101101
break;
102102
case 1:
103103
this.resourceSelectorPanel.ViewModel.ShowOnlyLocalResources = true;
104-
this.segmentedControl.SetImage (HostResources.GetNamedImage ("resource-editor-16"), 2);
104+
this.segmentedControl.SetImage (HostResources.GetNamedImage ("pe-resource-editor-16"), 2);
105105
break;
106106
case 2:
107107
this.resourceSelectorPanel.ViewModel.ShowOnlySystemResources = true;
108-
this.segmentedControl.SetImage (HostResources.GetNamedImage ("resource-editor-16~sel"), 2);
108+
this.segmentedControl.SetImage (HostResources.GetNamedImage ("pe-resource-editor-16~sel"), 2);
109109
break;
110110
}
111111

112112
this.resourceSelectorPanel.ReloadData ();
113113
});
114-
this.segmentedControl.SetImage (HostResources.GetNamedImage ("resource-editor-16"), 2);
114+
this.segmentedControl.SetImage (HostResources.GetNamedImage ("pe-resource-editor-16"), 2);
115115
this.segmentedControl.Frame = new CGRect ((FrameWidthThird - (segmentedControl.Bounds.Width) / 2), 5, (Frame.Width - (FrameWidthThird)) - 10, 24);
116116
this.segmentedControl.Font = NSFont.FromFontName (PropertyEditorControl.DefaultFontName, PropertyEditorControl.DefaultFontSize);
117117
this.segmentedControl.TranslatesAutoresizingMaskIntoConstraints = false;

Xamarin.PropertyEditing.Mac/Controls/RequestResource/ResourceTableDelegate.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public override NSView GetViewForItem (NSTableView tableView, NSTableColumn tabl
3838
var iconView = (NSImageView)tableView.MakeView (iconIdentifier, this);
3939
if (iconView == null) {
4040
iconView = new NSImageView {
41-
Image = this.hostResources.GetNamedImage ("resource-editor-32"),
41+
Image = this.hostResources.GetNamedImage ("pe-resource-editor-32"),
4242
ImageScaling = NSImageScale.None,
4343
Identifier = iconIdentifier,
4444
};
@@ -95,12 +95,12 @@ public override void SelectionDidChange (NSNotification notification)
9595
if (previousRow != -1
9696
&& previousRow < tableView.RowCount
9797
&& tableView.GetView (0, previousRow, false) is NSImageView previousIconColumn) {
98-
previousIconColumn.Image = this.hostResources.GetNamedImage ("resource-editor-32");
98+
previousIconColumn.Image = this.hostResources.GetNamedImage ("pe-resource-editor-32");
9999
}
100100

101101
if (tableView.SelectedRow != -1
102102
&& tableView.GetView (0, tableView.SelectedRow, false) is NSImageView selectedIconColumn) {
103-
selectedIconColumn.Image = this.hostResources.GetNamedImage ("resource-editor-32~sel");
103+
selectedIconColumn.Image = this.hostResources.GetNamedImage ("pe-resource-editor-32~sel");
104104
previousRow = tableView.SelectedRow;
105105
}
106106
}

Xamarin.PropertyEditing.Mac/HostResourceProvider.cs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System;
2+
using System.IO;
23
using AppKit;
34
using Foundation;
45

@@ -13,6 +14,15 @@ public NSAppearance CurrentAppearance
1314
set;
1415
}
1516

17+
private readonly NSBundle resourceBundle;
18+
19+
public HostResourceProvider ()
20+
{
21+
var containingDir = Path.GetDirectoryName (typeof (HostResourceProvider).Assembly.Location);
22+
var bundlePath = Path.Combine (containingDir, "PropertyEditingResource.bundle");
23+
this.resourceBundle = new NSBundle (bundlePath);
24+
}
25+
1626
public virtual NSAppearance GetVibrantAppearance (NSAppearance appearance)
1727
{
1828
if (appearance == null)
@@ -42,7 +52,7 @@ public virtual NSImage GetNamedImage (string name)
4252
name += "~sel";
4353
}
4454

45-
return NSImage.ImageNamed (name);
55+
return this.resourceBundle.ImageForResource (name);
4656
}
4757

4858
public virtual NSFont GetNamedFont (string name, nfloat fontSize)

0 commit comments

Comments
 (0)