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
/* 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
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)
{
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 () =>
@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;
public class CustomImageRenderer : ImageRenderer
{
MyRect imgBorderRect;
private Rect mBounds;
private Paint mBorderPaint;
protected override void OnElementChanged(ElementChangedEventArgs<Image> e)
{
base.OnElementChanged(e);
if (e.NewElement != null)
public List<T> GetListOfObjects<T>(string id) where T:class, IIdentity
{
lock (dbLock)
{
using (var sqlCon = new SQLiteConnection(App.Self.SQLitePlatform, App.Self.DBConnection))
{
sqlCon.Execute(DBClauseSyncOff);
string sql = string.Format("SELECT * FROM {0} WHERE id=?", GetName(typeof(T).ToString()));
var data = sqlCon.Query<T>(sql, id);
return data;
// picker
var picker = new Picker
{
HorizontalOptions = LayoutOptions.CenterAndExpand,
WidthRequest = App.ScreenSize.Width * .8
};
picker.Items.Add(LangResources.LangEnglish);
picker.Items.Add(LangResources.LangDanish);
picker.Items.Add(LangResources.LangDutch);
namespace mynamespace
{
using Xamarin.Forms;
public class TopBar : View
{
private string Title, LeftImage, RightImage;
Page currentPage;
public TopBar(string text = "", Page current = null, string leftImage = "", string rightImage = "")
public static class SendData
{
readonly static string BASEURL = "https://www.someurl.com/api";
static string Url;
public static HttpWebRequest SetupRequest
{
get
{
var request = WebRequest.Create(Url) as HttpWebRequest;
// from my DTO
public class PropertyChange : INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
protected virtual void OnPropertyChanged(string propertyName)
{
if (PropertyChanged == null)
return;