public EditDialog() : base(null, true) { this.emojiCollectionView = new UICollectionView(CoreGraphics.CGRect.Empty, new LineLayout(new CGSize(320, 120), false)); this.emojiCollectionView.RegisterClassForCell(typeof(EmojiCell), "emojiCell"); this.emojiCollectionView.BackgroundColor = UIColor.White; List <String> strings = new List <String> (); strings.AddRange(EmojiFactory.GetEmojieCodes()); EmojiSource source = new EmojiSource(strings); this.emojiCollectionView.Source = source; this.emojiCollectionView.Frame = new CoreGraphics.CGRect(0, 0, 320, 120); this.imagesCollectionView = new UICollectionView(CoreGraphics.CGRect.Empty, new LineLayout(new CGSize(120, 120), false)); this.imagesCollectionView.RegisterClassForCell(typeof(ImageCell), "imageCell"); this.imagesCollectionView.BackgroundColor = UIColor.White; this.imagesCollectionView.Frame = new CoreGraphics.CGRect(0, 0, 320, 120); this.videosCollectionView = new UICollectionView(CoreGraphics.CGRect.Empty, new LineLayout(new CGSize(120, 120), false)); this.videosCollectionView.RegisterClassForCell(typeof(ImageCell), "imageCell"); this.videosCollectionView.BackgroundColor = UIColor.White; this.videosCollectionView.Frame = new CoreGraphics.CGRect(0, 0, 320, 120); this.titleElement = new EntryElement("Title", "Title", ""); this.commentElement = new EntryElement("Comment", "Comment", ""); this.mapView = new MKMapView(); this.mapView.Layer.BorderColor = UIColor.Black.ColorWithAlpha(0.1f).CGColor; this.mapView.Layer.BorderWidth = 1f; this.mapView.Camera.Heading = 0; this.mapView.Camera.Pitch = 120; rotateCamera(); }
public EmojiViewController(IntPtr handle) : base(handle) { this.Title = "Take Emoji"; this.emojis = new List <string> (); this.emojis.AddRange(EmojiFactory.GetEmojieCodes()); Instance = this; }
public override void ViewDidAppear(bool animated) { base.ViewDidAppear(animated); UIBarButtonItem deleteItem = new UIBarButtonItem(UIBarButtonSystemItem.Trash, delegate { UIAlertView alert = new UIAlertView("Delete Moment", "Are you sure you want to delete this moment?", null, "Yes", "No"); alert.Clicked += (sender, e) => { if (e.ButtonIndex == 0) { AppDelegate.MomentsManager.DeleteMoment(this.moment); this.moment = null; this.NavigationController.PopViewController(true); } }; alert.Show(); }); this.NavigationController.SetToolbarHidden(false, true); this.SetToolbarItems(new UIBarButtonItem[] { new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace), deleteItem }, true); List <String> emojis = new List <string> (); emojis.AddRange(EmojiFactory.GetEmojieCodes()); if (this.moment.Emojis.Count > 0) { int index = emojis.IndexOf(this.moment.Emojis [0]); emojiCollectionView.ScrollToItem(NSIndexPath.FromRowSection(index, 0), UICollectionViewScrollPosition.CenteredHorizontally, false); } this.indicator = new UIActivityIndicatorView(new CGRect(0, 0, 30, 30)); this.indicator.Color = this.NavigationController.NavigationBar.TintColor; this.indicator.HidesWhenStopped = true; this.NavigationItem.RightBarButtonItem = new UIBarButtonItem(this.indicator); syncedChanged(); if (this.moment != null) { AppDelegate.MomentsManager.SyncMoment(this.moment); this.imagesCollectionView.ReloadData(); this.videosCollectionView.ReloadData(); } this.mapView.Frame = new CGRect(0, 0, this.TableView.Bounds.Width, 120); this.Reload(); AppDelegate.MomentsManager.Synced -= momentsSynced; AppDelegate.MomentsManager.Synced += momentsSynced; }
void Start() {//Create a Dictionary to contain all our Objects/Transforms System.Collections.Generic.Dictionary <string, Transform> colliders = new System.Collections.Generic.Dictionary <string, Transform>(); //Create our GameObjects and add their Transform components to the Dictionary we created above colliders.Add("Top", new GameObject().transform); colliders.Add("Bottom", new GameObject().transform); colliders.Add("Right", new GameObject().transform); colliders.Add("Left", new GameObject().transform); //Generate world space point information for position and scale calculations Vector3 cameraPos = Camera.main.transform.position; //Grab the world-space position values of the start and end positions of the screen, //then calculate the distance between them and store it as half, since we only need half that value for distance away from the camera to the edge screenSize.x = Vector2.Distance(Camera.main.ScreenToWorldPoint(new Vector2(0, 0)), Camera.main.ScreenToWorldPoint(new Vector2(Screen.width, 0))) * 0.5f; screenSize.y = Vector2.Distance(Camera.main.ScreenToWorldPoint(new Vector2(0, 0)), Camera.main.ScreenToWorldPoint(new Vector2(0, Screen.height))) * 0.5f; //For each Transform/Object in our Dictionary foreach (KeyValuePair <string, Transform> valPair in colliders) { BoxCollider2D newCollider = valPair.Value.gameObject.AddComponent <BoxCollider2D>(); //Add our colliders. Remove the "2D", if you would like 3D colliders. valPair.Value.name = valPair.Key + "Collider"; //Set the object's name to it's "Key" name, and take on "Collider". i.e: TopCollider valPair.Value.parent = transform; //Make the object a child of whatever object this script is on (preferably the camera) newCollider.isTrigger = true; if (valPair.Key == "Left" || valPair.Key == "Right") //Scale the object to the width and height of the screen, using the world-space values calculated earlier { valPair.Value.localScale = new Vector3(colThickness, screenSize.y * 3, colThickness); valPair.Value.gameObject.tag = "despawn"; } else { valPair.Value.localScale = new Vector3(screenSize.x * 3, colThickness, colThickness); } } //Change positions to align perfectly with outter-edge of screen, adding the world-space values of the screen we generated earlier, and adding/subtracting them with the current camera position, as well as add/subtracting half out objects size so it's not just half way off-screen colliders["Right"].position = new Vector3(cameraPos.x + screenSize.x + (colliders["Right"].localScale.x * 0.5f), cameraPos.y, zPosition); colliders["Left"].position = new Vector3(cameraPos.x - screenSize.x - (colliders["Left"].localScale.x * 0.5f), cameraPos.y, zPosition); colliders["Top"].position = new Vector3(cameraPos.x, cameraPos.y + screenSize.y + (colliders["Top"].localScale.y * 0.5f), zPosition); colliders["Bottom"].position = new Vector3(cameraPos.x, cameraPos.y - screenSize.y - (colliders["Bottom"].localScale.y * 0.5f), zPosition); colliders["Bottom"].gameObject.tag = "despawn"; factory = colliders["Top"].gameObject.AddComponent <EmojiFactory>(); }