This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | |
{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 () => |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 = "") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// from my DTO | |
public class PropertyChange : INotifyPropertyChanged | |
{ | |
public event PropertyChangedEventHandler PropertyChanged; | |
protected virtual void OnPropertyChanged(string propertyName) | |
{ | |
if (PropertyChanged == null) | |
return; |