Skip to content

Instantly share code, notes, and snippets.

View OHIHIYA20's full-sized avatar
🎯
Focusing

Rizal Ohihiya OHIHIYA20

🎯
Focusing
View GitHub Profile
@HenKun
HenKun / Readme.md
Last active January 8, 2025 23:54
MarkupExtension for Xamarin.Forms to have simple XAML inline converter

This is a simple MarkupExtension for Xamarin.Forms that imitates an if-else-statement. It was inspired by Thomas Levesque on https://stackoverflow.com/a/841894/6884587

Usage:

  1. Include xmlns:ext="clr-namespace:Xamarin.Forms.Extensions"
  2. Use on a bindable property: <Label Text="{ext:SwitchBinding IsLoggedIn, True=Log out, False=Log in}" />

You can also add a StringFormat:

@tylerchesley
tylerchesley / gist:6198074
Created August 9, 2013 23:10
Function to recursively copy files from an Android asset directory
public void copyFileOrDir(String path) {
AssetManager assetManager = this.getAssets();
String assets[] = null;
try {
assets = assetManager.list(path);
if (assets.length == 0) {
copyFile(path);
} else {
String fullPath = "/data/data/" + this.getPackageName() + "/" + path;
File dir = new File(fullPath);
@darkfall
darkfall / gist:1656050
Created January 22, 2012 07:15
A simple class that converts a image to a icon in c# without losing image color data, unlike System.Drawing.Icon; ico with png data requires Windows Vista or above
class PngIconConverter
{
/* input image with width = height is suggested to get the best result */
/* png support in icon was introduced in Windows Vista */
public static bool Convert(System.IO.Stream input_stream, System.IO.Stream output_stream, int size, bool keep_aspect_ratio = false)
{
System.Drawing.Bitmap input_bit = (System.Drawing.Bitmap)System.Drawing.Bitmap.FromStream(input_stream);
if (input_bit != null)
{
int width, height;