Skip to content

Instantly share code, notes, and snippets.

@Krumelur
Krumelur / gist:3537539
Created August 30, 2012 18:54
CATransform3D
/// <summary>
/// Sets the anchor point and translates the view so that it stays in its current position.
/// Normally, changing the anchor point also adjusts the view's position.
/// </summary>
/// <param name='oView'>the view whose anchor point has to be modified</param>
/// <param name='oNewAnchorPoint'>the new anchor point</param>
public void SetAnchorPointAndTranslate(PointF oNewAnchorPoint )
{
UIView oView = this;
PointF oNewPoint = new PointF(oView.Bounds.Width * oNewAnchorPoint.X, oView.Bounds.Height * oNewAnchorPoint.Y);
@Krumelur
Krumelur / gist:7042686
Created October 18, 2013 14:50
Smart INotifyPropertyChanged version. This allows you to do: public string SomeProperty { get { return base.GetProperty<string> (); } private set { base.SetProperty<string> (value); } } No need to fire anything manually. Name will be determined using CallerMemberNameAttribute.
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Runtime.CompilerServices;
namespace Xplat_Core
{
public class PropertyChangedBase : INotifyPropertyChanged
{
private Dictionary<string, object> properties = new Dictionary<string, object> ();
@Krumelur
Krumelur / EasyLayout Issue
Created February 25, 2014 08:34
EasyLayout Issue
using System;
using System.Collections.Generic;
using System.Linq;
using MonoTouch.Foundation;
using MonoTouch.UIKit;
using System.Drawing;
using Praeclarum.UI;
namespace LayoutTest
{
namespace GalaSoft.MvvmLight.Helpers
{
/// <summary>
/// A <see cref="BaseAdapter{T}"/> that can be used with an Android ListView. After setting
/// the <see cref="DataSource"/> and the <see cref="GetTemplate"/> properties, the adapter is
/// suitable for a list control. If the DataSource is an <see cref="INotifyCollectionChanged"/>,
/// changes to the collection will be observed and the UI will automatically be updated.
/// </summary>
/// <typeparam name="T">The type of the items contained in the <see cref="DataSource"/>.</typeparam>
////[ClassInfo(typeof(ObservableAdapter<T>),
@Krumelur
Krumelur / GroupedObservableCollection.cs
Created December 12, 2014 07:10
GroupedObservableCollection
/// <summary>
/// Grouped observable collection.
/// KEY_TYPE = the type used for the group key
/// ITEM_TYPE = the type used for the items of the list.
/// </summary>
public class GroupedObservableCollection<KEY_TYPE, ITEM_TYPE> : ObservableCollection<ITEM_TYPE>
{
/// <summary>
/// Gets the grouping key.
/// </summary>
using System.Collections.Generic;
using System;
using System.Collections.Specialized;
using Foundation;
using UIKit;
namespace LongRunningTasks
{
/// <summary>
@Krumelur
Krumelur / CocosSharpAsyncExtensions.cs
Created February 10, 2015 19:30
CocosSharp async extensions
public static class CocosExtensions
{
/// <summary>
/// Runs an action so that it can be awaited.
/// </summary>
/// <param name="node">Node.</param>
/// <param name="actions">Actions.</param>
public static Task<bool> RunActionsAsync(this CCNode node, params CCFiniteTimeAction[] actions)
{
var tcs = new TaskCompletionSource<bool> ();
using System;
using UIKit;
namespace MemoryTest
{
public class CustomView : UIView
{
public int magicNumber;
}
using CoreGraphics;
using Foundation;
using System;
using System.Runtime.CompilerServices;
using UIKit;
namespace MemoryTest
{
[Register("ViewController")]
public class ViewController : UIViewController
{
@Krumelur
Krumelur / CustomApp.cs
Created June 18, 2015 15:44
Shows how to detect any touch of the iOS screen
public class Application
{
// This is the main entry point of the application.
static void Main(string[] args)
{
UIApplication.Main(args, typeof(CustomApplication), typeof(AppDelegate));
}
}
// Inherits from UIApplication