private void Initialize()
        {
            mContactCardLayoutInfo = new ContactCardLayoutInfo();
            mContactCards          = new List <ContactCard>();
            mLastPosition          = new Vector2();
            mPositionIncrementer   = new Vector2();
            mItemsPerRow           = 0;
            mInitialized           = false;

            rootView = new View()
            {
                Size2D                 = new Size2D(Window.Instance.WindowSize.Width, Window.Instance.WindowSize.Height),
                BackgroundColor        = ROOTVIEW_COLOR,
                PositionUsesPivotPoint = false,
            };

            Window.Instance.Add(rootView);
        }
Exemple #2
0
        public ContactCard(ContactCardLayoutInfo contactCardLayoutInfo, string contactName, string contactAddress, string imagePath, Vector2 position, View rootView)
        {
            mContactCardLayoutInfo     = contactCardLayoutInfo;
            foldedPosition             = new Vector2(position.X, position.Y);
            mClippedImagePropertyIndex = -1;
            mFolded = true;

            //Window.Instance.KeyEvent += OnKeyEvent;

            // Create a View which will be used for the background and to clip the contents
            mContactCard = new View();
            mContactCard.BackgroundColor        = Color.White;
            mContactCard.ClippingMode           = ClippingModeType.ClipChildren;
            mContactCard.ParentOrigin           = ParentOrigin.TopLeft;
            mContactCard.PivotPoint             = PivotPoint.TopLeft;
            mContactCard.PositionUsesPivotPoint = true;
            mContactCard.Position2D             = new Position2D((int)foldedPosition.X, (int)foldedPosition.Y);
            mContactCard.Size2D    = new Size2D((int)mContactCardLayoutInfo.foldedSize.Width, (int)mContactCardLayoutInfo.foldedSize.Height);
            mContactCard.KeyEvent += OnKeyEvent;

            Window.Instance.GetDefaultLayer().Add(mContactCard);
            rootView.Add(mContactCard);

            // Create the header which will be shown only when the contact is unfolded
            mHeader                        = new View();
            mHeader.Size2D                 = new Size2D((int)mContactCardLayoutInfo.headerSize.Width, (int)mContactCardLayoutInfo.headerSize.Height);
            mHeader.BackgroundColor        = HEADER_COLOR;
            mHeader.ParentOrigin           = ParentOrigin.TopLeft;
            mHeader.PivotPoint             = PivotPoint.TopLeft;
            mHeader.PositionUsesPivotPoint = true;
            mHeader.Position2D             = new Position2D((int)mContactCardLayoutInfo.headerFoldedPosition.X, (int)mContactCardLayoutInfo.headerFoldedPosition.Y);

            // Create a clipped image (whose clipping can be animated)
            mClippedImage                        = ClippedImage.Create(imagePath);
            mClippedImage.Size2D                 = new Size2D((int)mContactCardLayoutInfo.imageSize.Width, (int)mContactCardLayoutInfo.imageSize.Height);
            mClippedImage.ParentOrigin           = ParentOrigin.TopLeft;
            mClippedImage.PivotPoint             = PivotPoint.TopLeft;
            mClippedImage.PositionUsesPivotPoint = true;
            mClippedImage.Position2D             = new Position2D((int)mContactCardLayoutInfo.imageFoldedPosition.X, (int)mContactCardLayoutInfo.imageFoldedPosition.Y);
            mClippedImage.Hide();
            mContactCard.Add(mClippedImage);

            // Create an image with a mask which is to be used when the contact is folded
            mMaskedImage                        = MaskedImage.Create(imagePath);
            mMaskedImage.Size2D                 = new Size2D((int)mContactCardLayoutInfo.imageSize.Width, (int)mContactCardLayoutInfo.imageSize.Height);
            mMaskedImage.ParentOrigin           = ParentOrigin.TopLeft;
            mMaskedImage.PivotPoint             = PivotPoint.TopLeft;
            mMaskedImage.PositionUsesPivotPoint = true;
            mMaskedImage.Position2D             = new Position2D((int)mContactCardLayoutInfo.imageFoldedPosition.X, (int)mContactCardLayoutInfo.imageFoldedPosition.Y);
            mContactCard.Add(mMaskedImage);

            // Add the text label for just the name
            mNameText = new TextLabel(contactName);
            //mNameText.StyleName = "ContactNameTextLabel";
            mNameText.TextColor              = new Color(0, 0, 0, 1);
            mNameText.HorizontalAlignment    = HorizontalAlignment.Center;
            mNameText.PointSize              = 14;
            mNameText.ParentOrigin           = ParentOrigin.TopLeft;
            mNameText.PivotPoint             = PivotPoint.TopLeft;
            mNameText.PositionUsesPivotPoint = true;
            mNameText.WidthResizePolicy      = ResizePolicyType.FillToParent;
            mNameText.Position2D             = new Position2D((int)mContactCardLayoutInfo.textFoldedPosition.X, (int)mContactCardLayoutInfo.textFoldedPosition.Y);
            mContactCard.Add(mNameText);

            // Create the detail text-label
            string detailString = contactName;

            detailString += "\n\n";
            detailString += contactAddress;

            mDetailText = new TextLabel(detailString);
            //mDetailText.StyleName = "ContactDetailTextLabel";
            mDetailText.TextColor              = new Color(0, 0, 0, 1);
            mDetailText.MultiLine              = true;
            mDetailText.PointSize              = 20;
            mDetailText.ParentOrigin           = ParentOrigin.TopLeft;
            mDetailText.PivotPoint             = PivotPoint.TopLeft;
            mDetailText.PositionUsesPivotPoint = true;
            mDetailText.Position2D             = new Position2D((int)mContactCardLayoutInfo.textFoldedPosition.X, (int)mContactCardLayoutInfo.textFoldedPosition.Y);
            mDetailText.Size2D  = new Size2D((int)(mContactCardLayoutInfo.unfoldedSize.Width - mContactCardLayoutInfo.textFoldedPosition.X * 2.0f), 0);
            mDetailText.Opacity = 0.0f;

            // Attach tap detection to the overall clip control
            mTapDetector = new TapGestureDetector();
            mTapDetector.Attach(mContactCard);
            mTapDetector.Detected += OnTap;
        }