Skip to content

Instantly share code, notes, and snippets.

View nodoid's full-sized avatar

Paul Johnson nodoid

  • Shining Knight Software
  • Merseyside, UK
View GitHub Profile
@nodoid
nodoid / rightmenu.cs
Last active January 12, 2016 00:17
Sweep from right menu
// topbar.cs - this is used to replace the navigation bar
public class TopBar : View
{
private string Title, LeftImage, RightImage;
readonly Page currentPage;
StackLayout panel;
Image rightCell;
Grid grid;
MenuView menu;
IMediaPicker media;
btnTakePic.Clicked += async delegate
{
try
{
progressStack.IsVisible = progressStack.IsEnabled = true;
App.Self.Uploaded = 0;
var mediaFile = await media.TakePhotoAsync(new CameraMediaStorageOptions { DefaultCamera = CameraDevice.Front, MaxPixelDimension = 400 });
Device.BeginInvokeOnMainThread(async () =>
public static class DateTimeUtils
{
public static DateTime NSDateToDateTime(this NSDate date)
{
var reference = TimeZone.CurrentTimeZone.ToLocalTime(new DateTime(2001, 1, 1, 0, 0, 0));
return reference.AddSeconds(date.SecondsSinceReferenceDate);
}
public static NSDate DateTimeToNSDate(this DateTime date)
{
/* App.ScreenSize is obtained from the platform by DI */
// this code is completely untested!
public class MyGrid : ContentPage
{
public class MyGrid()
{
var grid = new Grid
{
WidthRequest = App.ScreenSize.Width
yourPCLNamespace.App.ScreenSize = new Size(bounds.Width, bounds.Height);
async Task Scroller(StackLayout layout, ScrollView scroll, int position)
{
await Task.Delay(layout.Children.Count * 10).ContinueWith((y) =>
{
if (y.IsCompleted)
{
var selected = layout.Children[position];
Device.BeginInvokeOnMainThread(async () => await scroll.ScrollToAsync((StackLayout)selected, ScrollToPosition.Center, true));
}
});
@nodoid
nodoid / ModalView
Created October 19, 2017 13:48
Dialog box
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
style="@style/lightbox_dialog">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center_vertical|center_horizontal">
<?php
if(isset($_GET['url']))
{
echo "in";
$url = $_GET['url'];
echo $url;
$images = glob($url."*.{jpg,jpeg,png,gif}", GLOB_BRACE);
@nodoid
nodoid / gist:5abcceae070a98a7f44e966584bd5aa6
Created November 13, 2018 15:24
forms navservice for mvvmlvght
public class NavigationService : INavigationService
{
readonly Dictionary<string, Type> _pagesByKey = new Dictionary<string, Type>();
NavigationPage _navigation;
public string CurrentPageKey
{
get
{
lock (_pagesByKey)
@nodoid
nodoid / MainActivity.cs
Created March 16, 2019 11:25
Xamarin android permissions
/* you need the xamarin permissions to use this /*
static readonly int REQUEST_WRITESETTINGS = 2, REQUEST_EXTERNAL = 4, REQUEST_WIFI = 5, REQUEST_WAKELOCK = 6, REQUEST_CONTACTS;
static string[] PERMISSIONS_SETTINGS = { Manifest.Permission.WriteSettings };
static string[] PERMISSIONS_STORAGE = { Manifest.Permission_group.Storage };
static string[] PERMISSIONS_WIFISTATE = { Manifest.Permission.AccessWifiState };
static string[] PERMISSIONS_WAKELOCK = { Manifest.Permission.WakeLock };
static string[] PERMISSIONS_CONTACTS = { Manifest.Permission.ReadContacts };