I'm using C# Xamarin, and SkiaSharp to render image from resource folder. But I cannot get the correct image location.
Where I can find this image when run project? I try to looking for but no result:
You can get resource directory path using DirectoryInfo
https://samsung.github.io/TizenFX/API4/api/Tizen.Applications.DirectoryInfo.html#Tizen_Applications_DirectoryInfo_Resource
Here is a example that how to use
https://github.com/xamarin/Xamarin.Forms/blob/b59bb767a4367240983e93ab8e1a9a050dfea23b/Xamarin.Forms.Platform.Tizen/ResourcePath.cs#L27-L30
Thank you #Seungkenun Le. Base on his comment, I write a simple function to get resource path in Tizen Watch for Xamarin:
/// <summary>
/// Gets the resource path.
/// </summary>
/// <returns></returns>
internal static string GetResourcePath()
{
Tizen.Applications.Application app = Tizen.Applications.Application.Current;
if (app != null)
{
string resourcePath = app.DirectoryInfo.Resource;
if (Directory.Exists(resourcePath))
{
return resourcePath;
}
}
return string.Empty;
}
Related
I'm having a problem on xamarin ios and android.
if the device has set the text and display size to large, all the sizes in my app become enlarged.
how can I set the default size when opening the app?
add following code in main activity android
//For android
#region Reset Fonts to default
/// <summary>
/// Reset fonts.
/// </summary>
public override Resources Resources
{
get
{
Resources res = base.Resources;
Configuration config = new Configuration();
config.SetToDefaults();
res.UpdateConfiguration(config, res.DisplayMetrics);
return res;
}
}
#endregion
//
I'm trying to get map layers working in my Windows 8.1 app, which is using the Bing Maps SDK. Following microsoft's documentation, I created this code, and it doesn't seem to be working. No errors are thrown, making this problem even more confusing.
MapTileLayer tileLayer = new MapTileLayer();
tileLayer.TileSource = string.Format("http://mesonet.agron.iastate.edu/cache/tile.py/1.0.0/nexrad-n0q-900913/{{zoomLevel}}/{{x}}/{{y}}.png?{0}", DateTime.Now.ToString());
rMap.TileLayers.Add(tileLayer);
The URI variables zoomLevel,x, and y represent where to load the tile. 0 is the subdomain (This code was ported from Windows Phone 8, where it works fine
The Windows Phone 8 and Windows 8 are not the same control at all as for WP8 it's provided by Here and on Win8 it's provided by Microsoft.
Anyway, you can do what you want by using the following code:
/// <summary>
/// Invoked when this page is about to be displayed in a Frame.
/// </summary>
/// <param name="e">Event data that describes how this page was reached. The Parameter
/// property is typically used to configure the page.</param>
protected override async void OnNavigatedTo(NavigationEventArgs e)
{
Bing.Maps.MapTileLayer layer = new Bing.Maps.MapTileLayer();
layer.GetTileUri += layer_GetTileUri;
this.map.TileLayers.Add(layer);
}
private async void layer_GetTileUri(object sender, Bing.Maps.GetTileUriEventArgs e)
{
e.Uri = this.ComposeMyCustomUri(e);
}
You will find e is a specific parameter object of type GetTileUriEventArgs, see:
http://msdn.microsoft.com/en-us/library/jj672952.aspx
I have a simple webapi2 project.
The only information I can seem to find myself refers to the older webapi1
From my controller if I have
/// <summary>
/// Gets a list of not very interesting information
/// </summary>
/// <returns>The list</returns>
[ResponseType(typeof(ExampleModel))]
public IHttpActionResult Get()
{
var data = new List<ExampleModel>()
{
new ExampleModel()
{
Date = DateTime.Now,
Name = "Tom"
},
new ExampleModel()
{
Date = DateTime.Now.AddDays(-20),
Name = "Bob"
}
};
why is no information appearing when I try browse to the help page. I am told No documentation available.
Is there a magic switch somewhere that will turn on automated population of this data?
if you referring to displaying the xml comments, then you can find my answer here:
ASP.NET Web API Help Page documentation using Xml comments on controllers
Be sure to uncomment this code in Areas/HelpPage/App_Start/HelpPageConfig.cs
// Uncomment the following to use the documentation from XML documentation file.
config.SetDocumentationProvider(new XmlDocumentationProvider(HttpContext.Current.Server.MapPath("~/App_Data/XmlDocument.xml")));
Also make sure the xml file goes in App_Data not bin where it defaults to in project properties
Is it possible to upload images to Windows azure blob storage from a SQL SSIS package? SSIS will read new images (on daily basis) from one of my on-Premise SQL Server (table) and upload images to blob storage.
What a fun question this was! I got to thread together a lot of pieces that I had never tried.
I first built out a simple console app based on the fine manual over on HOW TO: Blob Storage. Knowing that I had working code allowed me to adapt it for SSIS.
I created 3 SSIS Variables at the Package level. AccountName, AccountKey and ContainerName. They are all data type String. These provide credentials + the folder where my uploaded data will reside.
Data Flow
The general look of your data flow is rather simple. A data source to a Script Component that will act as a Destination. You will need two columns: one provides a unique name for the blob and the other will be the binary bits.
My source is a trivial table. It has Country Names and their flag (stored as varbinary(max)) which you yourself can scrape from the CIA World Handbook if you're so inclined.
The Destination will be a bit of C#. Add a Script Component of type Destination.
On the Script tab, I have 3 ReadOnly Variables listed User::AccountKey,User::AccountName,User::ContainerName
On the Input Columns tab, I select CountryName and FlagImage.
The script itself follows. As noted in the How To, you will need to add a reference to Microsoft.WindowsAzure.Storage assembly before you can access the last 3 assemblies there.
using System;
using System.Data;
using System.IO;
using Microsoft.SqlServer.Dts.Pipeline.Wrapper;
using Microsoft.SqlServer.Dts.Runtime.Wrapper;
// Must add reference to Microsoft.WindowsAzure.Storage for this to work
// http://www.windowsazure.com/en-us/develop/net/how-to-guides/blob-storage/
using Microsoft.WindowsAzure.Storage;
using Microsoft.WindowsAzure.Storage.Auth;
using Microsoft.WindowsAzure.Storage.Blob;
/// <summary>
/// Watch me load data to Azure from SSIS
/// </summary>
[Microsoft.SqlServer.Dts.Pipeline.SSISScriptComponentEntryPointAttribute]
public class ScriptMain : UserComponent
{
/// <summary>
/// The storage account used
/// </summary>
private CloudStorageAccount storageAccount;
/// <summary>
/// An entity to work with the Blobs
/// </summary>
private CloudBlobClient blobClient;
/// <summary>
/// Blobs live in containers
/// </summary>
private CloudBlobContainer container;
/// <summary>
/// blockBlob instead of a pageBlob
/// </summary>
private CloudBlockBlob blockBlob;
/// <summary>
/// This method is called once, before rows begin to be processed in the data flow.
///
/// You can remove this method if you don't need to do anything here.
/// </summary>
public override void PreExecute()
{
base.PreExecute();
string cs = string.Empty;
string csTemplate = string.Empty;
string accountName = string.Empty;
string accountKey = string.Empty;
string containerName = string.Empty;
accountName = Variables.AccountName;
accountKey = Variables.AccountKey;
containerName = Variables.ContainerName;
csTemplate = "DefaultEndpointsProtocol=https;AccountName={0};AccountKey={1}";
cs = string.Format(csTemplate, accountName, accountKey);
this.storageAccount = CloudStorageAccount.Parse(cs);
this.blobClient = this.storageAccount.CreateCloudBlobClient();
this.container = this.blobClient.GetContainerReference(containerName);
this.container.CreateIfNotExists();
this.container.SetPermissions(new BlobContainerPermissions { PublicAccess = BlobContainerPublicAccessType.Blob });
}
/// <summary>
/// For each row passing through, upload to Azure
/// </summary>
/// <param name="Row">The row that is currently passing through the component</param>
public override void Input0_ProcessInputRow(Input0Buffer Row)
{
string blobName = string.Empty;
using (MemoryStream memStream = new MemoryStream(Row.FlagImage.GetBlobData(0, (int)Row.FlagImage.Length)))
{
this.blockBlob = this.container.GetBlockBlobReference(Row.CountryName);
this.blockBlob.UploadFromStream(memStream);
}
}
}
Global Assembly Cache (GAC)
Assemblies you wish to use within SSIS must reside in the GAC. Assemblies cannot go into the GAC unless they are signed. Fortunately, the Azure assemblies are signed so from a Visual Studio Command Prompt, type gacutil -if "C:\Program Files\Microsoft SDKs\Windows Azure\.NET SDK\v2.1\ref\Microsoft.WindowsAzure.Storage.dll" or the equivalent of where your version of that assembly exists
Load successful
And as proof, here's a shot from Azure Storage Explorer
SSIS 2012 and above now have a Microsoft-supported task to upload/download data to Azure Storage:
Example. "Microsoft SQL Server 2016 Integration Services Feature Pack for Azure": https://www.microsoft.com/en-us/download/details.aspx?id=49492
just search for 2012 and 2014 if that's what you are using.
Hope that helps!
I am dynamically downloading a XAP file that has an embedded resource assembly, with a single resource file (ApplicationStrings.fr-CA.resx). I am using WebClient to pull down the XAP file and using the following code to load the assembly, based on work done by Jeff Prosise in this post: http://www.wintellect.com/CS/blogs/jprosise/archive/2010/06/21/dynamic-localization-in-silverlight.aspx.
Note that I also manually create the XAP file from the fr-CA folder with assembly and the ApplicationManifest.xaml, as described by Guy Smith-Ferrier's steps listed in his presentation here http://www.guysmithferrier.com/post/2010/10/Building-Localized-XAP-Resource-Files-For-Silverlight-4.aspx.
// Get the application manifest from the downloaded XAP
StreamResourceInfo sri = new StreamResourceInfo(e.Result, null);
XmlReader reader = XmlReader.Create(Application.GetResourceStream(sri, new Uri("AppManifest.xaml", UriKind.Relative)).Stream);
AssemblyPartCollection parts = new AssemblyPartCollection();
// Enumerate the assemblies in the downloaded XAP
if (reader.Read())
{
reader.ReadStartElement();
if (reader.ReadToNextSibling("Deployment.Parts"))
{
while (reader.ReadToFollowing("AssemblyPart"))
{
parts.Add(new AssemblyPart() { Source = reader.GetAttribute("Source") });
}
}
}
// Load the satellite assemblies
foreach (AssemblyPart part in parts)
{
if (part.Source.ToLower().Contains("resources"))
{
Stream assembly = Application.GetResourceStream(sri, new Uri(part.Source, UriKind.Relative)).Stream;
part.Load(assembly);
}
}
// Change the culture
Thread.CurrentThread.CurrentCulture = culture;
Thread.CurrentThread.CurrentUICulture = culture;
The assembly seems to load ok, and I have matched up namespaces with the default resource file (ApplicationStrings.resx) with the downloaded resource file (ApplicationStrings.fr-CA.resx). As seen the code, the culture is set for the current thread.
However, calls to ApplicationStrings.ResourceManager.GetString(...) do not return the resources for the set culture. For example, the following should return a string for the new culture (fr-CA), but always returns the default culture (en-US).
/// <summary>
/// Looks up a localized string similar to User Name:.
/// </summary>
public static string Label_UserName {
get {
return ResourceManager.GetString("Label_UserName", resourceCulture);
}
}
Any suggestions? Thanks.
** UPDATE
I figured it out...I had forgotten to reset my supported locals in my satellite assembly project file:
<SupportedCultures>fr-CA</SupportedCultures>
I also made my folder structure exactly as it is for the default resources in my main Silverlight application.