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

Commit d91e9f8

Browse files
author
Dominique Louis
committed
Add pe- prefix to all image resources and use BundleResource for easier distribution.
1 parent 6585cc3 commit d91e9f8

File tree

168 files changed

+207
-184
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

+207
-184
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->'$(OutDir)\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
@@ -39,7 +39,7 @@ public PropertyButton (IHostResourceProvider hostResources)
3939
AccessibilityTitle = LocalizationResources.AccessibilityPropertiesButton;
4040
AccessibilityHelp = LocalizationResources.AccessibilityPropertiesButtonDescription;
4141
Enabled = true;
42-
Image = this.hostResources.GetNamedImage ("property-button-default-mac-10");
42+
Image = this.hostResources.GetNamedImage ("pe-property-button-default-mac-10");
4343
ImageScaling = NSImageScale.None;
4444
ToolTip = Properties.Resources.Default;
4545

@@ -124,27 +124,27 @@ private void ToggleFocusImage (bool focused = false)
124124

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

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

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

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

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

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

150150
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: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,13 @@ public NSAppearance CurrentAppearance
1313
set;
1414
}
1515

16+
private readonly NSBundle resourceBundle;
17+
18+
public HostResourceProvider ()
19+
{
20+
this.resourceBundle = new NSBundle ("../../../PropertyEditingResource.bundle");
21+
}
22+
1623
public virtual NSAppearance GetVibrantAppearance (NSAppearance appearance)
1724
{
1825
if (appearance == null)
@@ -42,7 +49,7 @@ public virtual NSImage GetNamedImage (string name)
4249
name += "~sel";
4350
}
4451

45-
return NSImage.ImageNamed (name);
52+
return this.resourceBundle.ImageForResource (name);
4653
}
4754

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

0 commit comments

Comments
 (0)