void Create(CreateParams parentParams, float deviceHeight, PointF startPos, string startingText, UserNoteChanged onUserNoteChanged) { Initialize( ); OnUserNoteChanged = onUserNoteChanged; PositionTransform = new PointF(parentParams.Width, parentParams.Height); //setup our timer for allowing movement/ /*DeleteTimer = new System.Timers.Timer(); * DeleteTimer.Interval = 1000; * DeleteTimer.Elapsed += DeleteTimerDidFire; * DeleteTimer.AutoReset = false;*/ // take the UserNote default style, because they aren't part of the XML stream and have nothing to inherit. mStyle = ControlStyles.mUserNote; // flag that we want this text field to grow as more text is added TextView.ScaleHeightForText = true; // Setup the font TextView.SetFont(mStyle.mFont.mName, mStyle.mFont.mSize.Value); TextView.TextColor = mStyle.mFont.mColor.Value; TextView.Placeholder = MessagesStrings.UserNote_Placeholder; TextView.PlaceholderTextColor = ControlStylingConfig.TextField_PlaceholderTextColor; TextView.KeyboardAppearance = GeneralConfig.iOSPlatformUIKeyboardAppearance; TextView.SetOnEditCallback( delegate(PlatformTextView textView) { InvokeChangedCallback( ); }); // check for border styling if (mStyle.mBorderColor.HasValue) { TextView.BorderColor = mStyle.mBorderColor.Value; } if (mStyle.mBorderRadius.HasValue) { TextView.CornerRadius = mStyle.mBorderRadius.Value; } if (mStyle.mBorderWidth.HasValue) { TextView.BorderWidth = mStyle.mBorderWidth.Value; } if (mStyle.mBackgroundColor.HasValue) { TextView.BackgroundColor = mStyle.mBackgroundColor.Value; } // Setup the anchor BG int area = (int)Rock.Mobile.Graphics.Util.UnitToPx(50); Anchor.BackgroundColor = NoteConfig.UserNote_AnchorColor; Anchor.Bounds = new RectangleF(0, 0, area, area); // Setup the anchor color NoteIcon.Text = PrivateNoteConfig.UserNote_Icon; NoteIcon.TextColor = mStyle.mFont.mColor.Value;//NoteConfig.UserNote_IconColor; // get the small and large sizes for the note icon, so we can animate correctly NoteIcon.SetFont(PrivateControlStylingConfig.Icon_Font_Secondary, PrivateNoteConfig.UserNote_IconOpenSize); NoteIcon.Bounds = new RectangleF(0, 0, area, 0); NoteIcon.SizeToFit(); NoteIconOpenSize = NoteIcon.Bounds.Size; NoteIcon.SetFont(PrivateControlStylingConfig.Icon_Font_Secondary, PrivateNoteConfig.UserNote_IconClosedSize); NoteIcon.Bounds = new RectangleF(0, 0, area, 0); NoteIcon.SizeToFit( ); NoteIconClosedSize = NoteIcon.Bounds.Size; //// // store the width of the screen so we know // what the remaining width is when moving the note around. ScreenWidth = parentParams.Width * .95f; // Don't let the note's width be less than twice the anchor width. Any less // and we end up with text clipping. MinNoteWidth = (Anchor.Bounds.Width * 2); // Dont let the note be any wider than the screen - twice the min width. This allows a little // free play so it doesn't feel like the note is always attached to the right edge. MaxNoteWidth = Math.Min(ScreenWidth - MinNoteWidth, (MinNoteWidth * 6)); // set the allowed X/Y so we don't let the user move the note off-screen. // for x, we need 3 values. Open, Closed, and current MaxAllowedX_Open = (ScreenWidth - MinNoteWidth - Anchor.Bounds.Width); MaxAllowedX_Closed = (ScreenWidth - Anchor.Bounds.Width); CurrMaxAllowedX = MaxAllowedX_Open; MaxAllowedY = (parentParams.Height - Anchor.Bounds.Height); MaxAllowedY *= 1.05f; float width = Math.Max(MinNoteWidth, Math.Min(MaxNoteWidth, MaxAllowedX_Open - startPos.X)); TextView.Bounds = new RectangleF(0, 0, width, 0); UtilityLayer.BackgroundColor = TextView.BackgroundColor; UtilityLayer.CornerRadius = TextView.CornerRadius; UtilityLayer.BorderWidth = TextView.BorderWidth; UtilityLayer.BorderColor = TextView.BorderColor; UtilityLayer.Bounds = new RectangleF(0, 0, MinNoteWidth, 0); // setup the delete button DeleteButton.Text = PrivateNoteConfig.UserNote_DeleteIcon; DeleteButton.TextColor = mStyle.mFont.mColor.Value;//NoteConfig.UserNote_IconColor; DeleteButton.SetFont(PrivateControlStylingConfig.Icon_Font_Secondary, PrivateNoteConfig.UserNote_DeleteIconSize); DeleteButton.SizeToFit( ); // setup the close button CloseButton.Text = PrivateNoteConfig.UserNote_CloseIcon; CloseButton.TextColor = mStyle.mFont.mColor.Value;//NoteConfig.UserNote_IconColor; CloseButton.SetFont(PrivateControlStylingConfig.Icon_Font_Secondary, PrivateNoteConfig.UserNote_CloseIconSize); CloseButton.SizeToFit( ); // Setup the initial positions Anchor.Position = startPos; AnchorFrame = Anchor.Frame; AnchorTouchMaxDist = AnchorFrame.Width / 2; AnchorTouchMaxDist *= AnchorTouchMaxDist; NoteIcon.Position = new PointF(Anchor.Frame.Left + (Anchor.Frame.Width - NoteIconClosedSize.Width) / 2, Anchor.Frame.Top + (Anchor.Frame.Height - NoteIconClosedSize.Height) / 2); // set the actual note TextView relative to the anchor TextView.Position = new PointF(AnchorFrame.Left + AnchorFrame.Width / 2, AnchorFrame.Top + AnchorFrame.Height / 2); UtilityLayer.Position = new PointF((TextView.Position.X + width) - UtilityLayer.Bounds.Width, TextView.Position.Y - Rock.Mobile.Graphics.Util.UnitToPx(UtilityLayerHeight) + 1); // set the position for the delete button DeleteButton.Position = new PointF(UtilityLayer.Position.X + DeleteButton.Bounds.Width / 2, UtilityLayer.Position.Y + (Rock.Mobile.Graphics.Util.UnitToPx(UtilityLayerHeight) - DeleteButton.Bounds.Height) / 2); CloseButton.Position = new PointF(UtilityLayer.Frame.Right - (CloseButton.Bounds.Width + (CloseButton.Bounds.Width / 2)), UtilityLayer.Position.Y + (Rock.Mobile.Graphics.Util.UnitToPx(UtilityLayerHeight) - CloseButton.Bounds.Height) / 2); // validate its bounds ValidateBounds( ); // set the starting text if it was provided if (startingText != null) { TextView.Text = startingText; } TextView.Hidden = true; SetDebugFrame(TextView.Frame); }