Xamarin Android: F# icon not being picked up by Resources - f#

Create an F# Xamarin Android project in Visual Studio 10.
The template contains a set of mipmap folders, to which you can add your own icons.
If I add the icon my_icon.png to each of the mipmap folders, then they should be picked up as a drawable resource: i.e. I should be able to use
type MyResources = MyProject.Resource
and then the compiler should pick up
let myIcon = MyResources.Drawable.my_icon
But it isn't.
Is this a bug? And is there a workaround?

The answer is laughably obvious.
The resource lives in MyResources.Mipmap:
let myIcon = MyResources.Mipmap.my_icon

Related

Xamarin add-in reference installation location

I am writing a plugin that adds a project template. This template needs to use some files that the default templates use too.
I am looking for something like the ${ProjectName} variable but for the installation folder. Does something like this exist or is there some other workaround I can use?
Here is
<Files>
<Directory name="Resources">
<RawFile name="Default.png" src="${Reference To Installation Folder}/Templates/iOS/Default.png" />
<RawFile name="Default#2x.png" src="${Reference To Installation Folder}/Templates/iOS/Default#2x.png" />
</Directory>
</Files>
By installation folder I am assuming you mean where Xamarin Studio is installed.
I am also assuming that you cannot distribute the files with your addin since they are part of Xamarin Studio and not available with just MonoDevelop.
There is no property/parameter that specifies where Xamarin Studio is installed as far as I am aware.
The src attribute in RawFile does not support having parameters being replaced so even if there was a parameter which pointed to where Xamarin Studio was installed it could not be used.
So you are left with two options that I can think of:
Implement a wizard for your project template.
Implement your own RawFile template.
A project template wizard would mean you could only support Xamarin Studio 5.9 and above. So I will ignore this for now. Both the above options are similar in how they are implemented.
For your own version of the RawFile template you define the class to use in your addin.xml file:
<Extension path = "/MonoDevelop/Ide/FileTemplateTypes">
<FileTemplateType name = "RawFileNoExtension" class = "MyAddin.MyRawFileExtensionTemplate"/>
</Extension>
Then you can create your own file extension template class. Here is an example taken from the existing RawFileDescriptionTemplate but I have removed some error handling:
public class MyRawFileExtensionTemplate : RawFileDescriptionTemplate
{
FilePath contentSrcFile;
public override void Load (XmlElement filenode, FilePath baseDirectory)
{
base.Load (filenode, baseDirectory);
var srcAtt = filenode.Attributes["src"];
// TODO: Replace src with path to Xamarin Studio.
contentSrcFile = FileService.MakePathSeparatorsNative (srcAtt.Value);
contentSrcFile = contentSrcFile.ToAbsolute (baseDirectory);
}
public override Stream CreateFileContent (SolutionItem policyParent, Project project, string language,
string fileName, string identifier)
{
return File.OpenRead (contentSrcFile);
}
}
You would need to replace the TODO section with code to find where Xamarin Studio is installed. One way to do that would be to find a type in one of Xamarin Studio's assemblies and then get the assembly's location.

Why TLF text works in debug on device mode but not in a release ad-hoc?

I have created a swf that include text TLF.
After that I have loaded it in an flex mobile application.
At the beginning I had lot of problems to load it.
1- First because I used Loader and the project was created with Flash Profesional. The best way is load it with ProLoader of flash library included in Flash Professional.
2- One time I finally loaded and tried it in the simulator on desktop I tried it in my iPad in Debug and fast compilation mode. I had the next error:
Error #2100: The ByteArray parameter in Loader.loadBytes() must have
length greater than 0.
I fixed it compiling in FLA the swf with the option in publish settings library "combined in code". Great! TLF in iPad works! In iOS works!
3- But when I built a release of the same code (that works previously on debug in a device), when I open it I only see images. Not text. Why works on debug and not on release??
Do you know what I forgot?
Thanks a lot in advance.
EDIT TO ADD SOME CODE
I embed the swfs and loads them in a item renderer. The list has a dataprovider of ids. And I load in each item renderer the swf corresponding with the id.
[Embed(source="/bin/histologia.swf")]
public const PAG_01:Class;
[Embed(source="/bin/histologia.swf")]
public const PAG_02:Class;
public function set data( value:Object ):void {
...
var pagAsset:Class = pagesAssets.assets[value];
var pag:MovieClip = new pagAsset();
var SWFClass:ByteArray = pag.movieClipData;
var ldrContext:LoaderContext = new LoaderContext(false, new ApplicationDomain(ApplicationDomain.currentDomain));
ldrContext.allowLoadBytesCodeExecution = true;
currentLoader.loadBytes(SWFClass, ldrContext);
¿loadBytes implies runtime code? =(
I read this in an Adobe article:
If do you use TLF text, I merged the code, the library of TLF into the swf, since iOS does not load RSLs at runtime.
What am I doing but?? How can I embed, and use it?
I think this answer would help me but I'm not sure
UPDATE 2
I have changed the code. Used the swf merge from #Jeff Ward but the result is the same. The swf is loaded but the TLF text is not shown.
var pagAsset:Class = pagesAssets.assets[value];
var pag:MovieClip = new pagAsset();
addChild(pag);
Why??

Can an XNA Game use IsolatedStorageSettings for WP7?

I've been trying to port some Windows Phone 7 code between Silverlight to XNA which relies on IsolatedStorageSettings but I can't get Visual Studio to resolve it. When I have a look at what Intellisense is resolving under System.IO.IsolatedStorage & it lists IsolatedStorageFile, IsolatedStorageException & IsolatedStorageStream.
The documentation says that the supported version is for Silverlight but I don't understand why I am seeing the difference because of the project types.
http://msdn.microsoft.com/query/dev10.query?appId=Dev10IDEF1&l=EN-US&k=k(SYSTEM.IO.ISOLATEDSTORAGE.ISOLATEDSTORAGESETTINGS);k(ISOLATEDSTORAGESETTINGS);k(TargetFrameworkMoniker-%22SILVERLIGHT,VERSION%3dV4.0%22);k(DevLang-CSHARP)&rd=true
Thanks
The following work for me in an XNA project with no extra project references:
using (var store = IsolatedStorageFile.GetUserStoreForApplication())
{
store.CreateFile("folder/file.ext");
}
After adding a reference to System.Windows.dll I can then do:
var settings = IsolatedStorageSettings.ApplicationSettings;
settings.Add("something", "myValue");
settings.Save();
If you can't get the above working, can you post an example of what you're trying.

Delphi: Organize RCData into hierarchy way

The following print screen shows list of resources file embedded into the package. Is it possible to organize the highlighted resources (SE_BUG...SY_VIEW) into hierarchy way ? What i mean here is that can I create a folder call Metadata under the folder RCData and move all the highlighted resources (SE_BUG...SY_VIEW) into the Metadata folder ? In other words, I want to achieve the highlighted resources in well organized such as the way of MainIcon folder.
the RCData is a type of resource not a folder. so you must use another type of resource to see the data in another folder.
This is the list of the types of resources available in delphi wich is based in the Windows Resources types.
const
RT_CURSOR = MakeIntResource(1);
RT_BITMAP = MakeIntResource(2);
RT_ICON = MakeIntResource(3);
RT_MENU = MakeIntResource(4);
RT_DIALOG = MakeIntResource(5);
RT_STRING = MakeIntResource(6);
RT_FONTDIR = MakeIntResource(7);
RT_FONT = MakeIntResource(8);
RT_ACCELERATOR = MakeIntResource(9);
RT_RCDATA = Types.RT_RCDATA; //MakeIntResource(10);
RT_MESSAGETABLE = MakeIntResource(11);
DIFFERENCE = 11;
RT_GROUP_CURSOR = MakeIntResource(DWORD(RT_CURSOR + DIFFERENCE));
RT_GROUP_ICON = MakeIntResource(DWORD(RT_ICON + DIFFERENCE));
RT_VERSION = MakeIntResource(16);
RT_DLGINCLUDE = MakeIntResource(17);
RT_PLUGPLAY = MakeIntResource(19);
RT_VXD = MakeIntResource(20);
RT_ANICURSOR = MakeIntResource(21);
RT_ANIICON = MakeIntResource(22);
the MAINICON folder in your sample image is a RT_GROUP_ICON, wich represent a group of icons with different sizes and colors, because that they appear like a folder.
Resource files don't have a structure. All you have is a bunch of resources that are identified by two parameters: Name and resource type.The icon resource you see is of type "ICON" and is named "MAINICON" and is just an icon file. And icon files allow multiple images to be part of a single resource file. So what you're seeing is not the structure of the resource but the structure of the icon file as a special resource. The resource explorer is just capable of detecting these special resource files and thus displays them in this special way.So basically, you have a main icon which only contains an icon of 32x32 pixels x32-bits colors. If you'd used an icon file that contains multiple images, you would have seen more in that list.
The Resource Explorer demo comes with source code, so yes, you can. :-)

How do you SetMaxAttachmentSize in TFS 2010?

I want to set the maximum work item attachment size. From old blogs I have found that it is possible by calling SetMaxAttachmentSize, but the blogs are for older versions of TFS. I have found the new webservice path for TFS 2010.
http://localhost:8080/tfs/_tfs_resources/WorkItemTracking/v1.0/ConfigurationSettingsService.asmx/SetMaxAttachmentSize
Unfortunately when I call it like that I receive this error: This request can only be made against a project collection. The (.asmx) file should be located in the project directory (usually _tfs_resources under the application root).
I don't know how to format the call via a browser to target a specific project collection. Any thoughts?
Apparently SetMaxAttachmentSize web service was not leveraged on TFS 2010 therefore you need to do this programmatically, try running the following code:
TeamFoundationServer tfs = TeamFoundationServerFactory.GetServer(#"http://yourtfsserver:8080/tfs/DefaultCollection");
ITeamFoundationRegistry rw = tfs.GetService<ITeamFoundationRegistry>();
RegistryEntryCollection rc = rw.ReadEntries(#"/Service/WorkItemTracking/Settings/MaxAttachmentSize");
RegistryEntry re = new RegistryEntry(#"/Service/WorkItemTracking/Settings/MaxAttachmentSize", "20971520"); //20MB
if (rc.Count != 0)
{
re = rc.First();
re.Value = "20971520";
}
rw.WriteEntries(new List<RegistryEntry>() { re });
I hope it works for you
Regards,
Randall Rosales
I have found that this works. It is easier than writing code.
Go to this url replacing <Collection> with your project collection: http://localhost:8080/tfs/<Collection>/WorkItemTracking/v1.0/ConfigurationSettingsService.asmx
Choose SetMaxAttachmentSize
You can test to make sure you set it correctly by going to the same url above and then selecting GetMaxAttachmentSize.

Resources