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 / uipickerview example
Created February 26, 2015 15:22
UIPickerViews
// place this in your controller
// View is the view the control sits in
// txtSelect is the name of the textbox the spinner "sits" in - as soon as you select
// the textbox, the UIPickerView fires up
// information is a List<string>
txtSelect.EditingDidBegin += delegate
{
txtSelect.InputView = PickerUI.CreateDropList(View, new UIPickerView(), txtSelect, information);
};
@nodoid
nodoid / Android styled button
Created February 26, 2015 21:17
Styling an android button
// in Resources/drawable
// I've called this RoundedButton.xml
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android" >
<item android:state_pressed="true" >
<shape android:shape="rectangle" >
<corners android:radius="3dip" />
<stroke android:width="1dip" android:color="#5e7974" />
<gradient android:angle="-90" android:startColor="#345953" android:endColor="#689a92" />
@nodoid
nodoid / gist:6824538d40e120298c9e
Last active August 29, 2015 14:16
Using Get/Post
private T callService<T>(string method, string json, string auth, bool post = false, List<string> headers = null) where T : new()
{
string url = string.Format("{0}/{1}", _configuration.BaseUrl, method);
var request = WebRequest.Create(url) as HttpWebRequest;
request.Method = !post ? "GET" : "POST";
request.Accept = "application/json";
request.ContentType = "application/json";
request.Headers["Authorization"] = auth;
if (headers != null)
{
@nodoid
nodoid / gist:5da70ca571d9f9ee05c0
Last active August 29, 2015 14:23
Scroll on TextField enter
txtEmail.EditingDidBegin += delegate
{
UIUtils.SetKeyboardEditorWithCloseButton(txtEmail, UIKeyboardType.Default);
UIUtils.AnimateTextField(View, true);
};
txtEmail.EditingDidEnd += delegate
{
UIUtils.AnimateTextField(View, false);
};
// from my DTO
public class PropertyChange : INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
protected virtual void OnPropertyChanged(string propertyName)
{
if (PropertyChanged == null)
return;
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;
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 = "")
// 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);
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;
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)